(2)测试用例类
package junittest; import static org.junit.Assert.*; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.JUnitCore; public class MyMathTest { //将需要测试的类,声明成成员变量 MyMath math; //每次运行测试方法之前都会运行该方法 @Before public void setUp() { } //每次运行测试用例之后都会运行该方法 @After public void tearDown() { } //测试一元一次方程的求解 //expected=ArithmeticException.class //相当于断言该测试方法将会抛出ArithmeticException异常 @Test(expected=ArithmeticException.class) public void testOneEquation() { } //测试一元二次方程的求解 @Test public void testTwoEquation() { } } package junittest; import static org.junit.Assert.*; import org.junit.Test; public class HelloWorldTest { @Test public void testSayHello() { } @Test public void testAdd() { } } |