import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; class PointTest {1@Test void test1() { Point p = new Point(1000, 500);2assertEquals(p.getX(), 1000, "x"); } @Test void test2() { Point p = new Point(1000, 500); assertEquals(p.getY(), 500, "y"); } }
JUnit 5 org.junit.jupiter.api import static org.junit.jupiter.api.assertTrue; import static org.junit.BeforeEach etc JUnit <= 4 import static org.junit.Assert.assertTrue; import static org.junit.Before etc
System.out.println(testInfo.getDisplayName()); System.out.println(testInfo.getTags()); System.out.println(testInfo.getTestClass()); System.out.println(testInfo.getTestMethod()); @BeforeEach void init(TestInfo testInfo) { println(testInfo.getDisplayName()); } @Test @DisplayName("Test Edge Case -- Empty List") public void testEdgeCaseEmptyList { //... { @AfterEach void tearDown(TestInfo testInfo) { println(testInfo.getDisplayName()); }
/*public static void assertTrue(boolean b){ try{ Assert.assertTrue(b); System.out.println("PASSED"); }catch(AssertionError e){ System.out.println("FAILED"); throw e; } }*/
RuntimeException