4、l,matcher)查看实际值是否满足指定的条件fail()让测试失败2.示例[java]viewplaincopyprint?package test; import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import java.util.Arrays; import org.hamcrest.core.CombinableMatcher; import org.junit.Test; public class AssertTests {
5、 @Test public void testAssertArrayEquals() { byte[] expected = "trial".getBytes(); byte[] actual = "trial".getBytes(); org.junit.Assert.assertArrayEquals("failure - byte arrays not same", expected, actual); } @Test public voi
6、d testAssertEquals() { org.junit.Assert.assertEquals("failure - strings not same", 5l, 5l); } @Test public void testAssertFalse() { org.junit.Assert.assertFalse("failure - should be false", false); } @Test public void testAss
7、ertNotNull() { org.junit.Assert.assertNotNull("should not be null", new Object()); } @Test public void testAssertNotSame() { org.junit.Assert.assertNotSame("should not be same Object", new Object(), new Object()); }