package testcode; import static org.junit.Assert.assertEquals; public class AssertTest { public AssertTest() { test1(); test2(); } /** * The test code for Value * * @throws Exception */ public static void main(String[] args) throws Exception { new AssertTest(); } public static void test1() { assertEquals(1, 1); System.out.println("1ok"); } public static void test2() { try { assertEquals("not equal", 1, 2); System.out.println("Test did not fail properly"); return; } catch (AssertionError e) { if (!e.getMessage().contains("not equal")) { System.out.println( "Test threw as expected but message does not contain 'not equal'"); return; } System.out.println("2ok"); } } }