JavaHamcrest
JavaHamcrest copied to clipboard
hasProperty with value fails if the scope of the instance's class is not public
If an instance of a default scoped class is passed into the hasProperty matcher, the assertion will always fail when the get method is invoked to get the value of the property.
I believe this is the issue I'm seeing? My test case:
import org.junit.Test;
import java.nio.file.Path;
import java.nio.file.Paths;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
public class LibraryTest {
@Test
public void testSomeLibraryMethod() {
Path path = Paths.get("hi.txt");
assertThat(path.getFileName().toString(), is(equalTo("hi.txt")));
assertThat(path, hasProperty("fileName", hasToString("hi.txt")));
}
}