一、开发工具的安装
二、测试
1、被测试代码
package A1;
public class A3 {
public int add(int a, int b) {
return a + b;
}
public int substract(int a, int b) {
return a - b;
}
public int multiply(int a, int b) {
return a * b;
}
public int divide(int a, int b) {
return a / b;
}
}
2、测试代码导入
3、测试方法代码
package A1;
import static org.junit.Assert.*;
import org.junit.Test;
public class A4 {
@Test
public void test() {
assertEquals(2,new A3().add(1, 1));
}
@Test
public void test1() {
assertEquals(2,new A3().substract(3, 1));
}@Test
public void test2() {
assertEquals(2,new A3().multiply(2, 1));
}@Test
public void test3() {
assertEquals(2,new A3().divide(2, 1));
}
}
4、测试结果