Assert.assertEquals()
, Assert.assertTrue()
, etc. methods
which can be migrated to Hamcrest declarative style Assert.assertThat()
calls.
For example:
public class SubstantialTest {
@Test
public void testContents(Collection<String> c, String s) {
Assert.assertTrue(c.contains(s));
Assert.assertEquals(c, s);
Assert.assertNotNull(c);
Assert.assertNull(c);
Assert.assertFalse(c.contains(s));
}
}
A quick-fix is provided to perform the migration:
public class SubstantialTest {
@Test
public void testContents(Collection<String> c, String s) {
assertThat(c, hasItem(o));
assertThat(o, is(c));
assertThat(c, notNullValue());
assertThat(c, nullValue());
assertThat(c, not(hasItem(o)));
}
}
This inspection requires that the Hamcrest library is available on the classpath.
Use the Statically import matcher's methods option to specify if you want the quick-fix to statically import the Hamcrest matcher methods.