import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @Test public void test() { int expectedValue = 5; int actualValue = 5; assertEquals(expectedValue, actualValue); }
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.*; @Test public void test() { String expectedString = "hello"; String actualString = "world"; assertEquals(expectedString, actualString); }In this example, the assertEquals() method is used to compare two string values - the expected value of "hello" and the actual value of "world". Since these two values do not match, the test fails. Overall, the org.hamcrest.Matchers package library is a useful tool for writing tests in Java. It provides a set of matchers that can be used to test different types of values and objects, making it easier to write comprehensive and effective tests.