import org.junit.Test; public class MyTests { @Before public void setUp() { } @Test public void testMethod() { } @After public void tearDown() { } } import org.junit.Test; import static org.junit.Assert.assertEquals; public class MyTests { @Test public void testAddition() { int result = 2 + 3; assertEquals(5, result); } } import org.junit.runner.JUnitCore; import org.junit.runner.Result; import org.junit.runner.notification.Failure; public class MyTestRunner { public static void main(String[] args) { Result result = JUnitCore.runClasses(MyTests.class); for (Failure failure : result.getFailures()) { System.out.println(failure.toString()); } System.out.println(result.wasSuccessful()); } }


上一篇:
下一篇:
切换中文