Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Missing space in mismatch description #15

Open
mtc-janheyd opened this issue Nov 30, 2018 · 0 comments · Fixed by mrwilson/java-8-matchers#6 · May be fixed by #20
Open

Missing space in mismatch description #15

mtc-janheyd opened this issue Nov 30, 2018 · 0 comments · Fixed by mrwilson/java-8-matchers#6 · May be fixed by #20
Labels

Comments

@mtc-janheyd
Copy link

mtc-janheyd commented Nov 30, 2018

There is a space character missing in the description of OptionalMatchers.contains(Matcher<T> matcher) before the description of the sub-matcher.

import org.junit.Test;

import java.util.Optional;

import static co.unruly.matchers.OptionalMatchers.contains;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;

public class OptionalMatcherTest {

    @Test
    public void show_the_bug() {
        assertThat(Optional.of("foo"), contains(equalTo("bar")));
    }
}

This produces the following message:

java.lang.AssertionError: 
Expected: Optional with an item that matches"bar"
     but: was <Optional[foo]>
Expected :Optional with an item that matches"bar"
     
Actual   :<Optional[foo]>

This gets very confusing when using a FeatureMatcher because the FeatureMatcher does not quote its description so it just becomes something like

Expected: Optional with an item that matchesbar

which can be pretty hard to read.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
2 participants