Hi,
This is a cross-post from StackOverflow; I didn't realize in time there was a dedicated user group...
The original post can be found here: http://stackoverflow.com/q/26546618/2018047
I just started using Hamcrest, so I'm probably doing it all wrong.
I have a List<Foo> foos and the Foo interface looks a bit like this:
public abstract interface Foo {
public String getBar();
}It is implemented by impl.FooImpl:
public class FooImpl implements Foo {
protected String _bar;
public String getBar() {
return _bar;
}
}My assert looks like this:
assertThat(
foos,
Matchers.hasItem(
Matchers.<Foo> hasProperty(
"bar",
equalTo(Whitebox.<String> getInternalState(AnotherClass.class,"A_FIELD_NAME"))
)
)
);Unfortunately, JUnit/Hamcrest isn't happy:
java.lang.AssertionError:
Expected: a collection containing hasProperty("_bar", "someValue")
got: <[com.example.impl.FooImpl@2c78bc3b]>Any idea what I need to do to fix this?
Kind regards,
Christian
--
You received this message because you are subscribed to the Google Groups "Hamcrest Java Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to hamcrest-jav...@googlegroups.com.
To post to this group, send email to hamcre...@googlegroups.com.
Visit this group at http://groups.google.com/group/hamcrest-java.
For more options, visit https://groups.google.com/d/optout.
So, my actual property is called_FooBar, the getter is calledgetFooBar(), and the right matcher isMatchers.equalTo( "fooBar", "some value")... (Note the LOWERCASE "f".)