第二次作业

一、选择开发工具

开发工具我选择了之前略有接触过的Eclipse。

二、使用Eclipse

1、运行

2、编写需要被测试的JAVA类

public class Calculate {

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) {

// 这里只是最简单的测试demo,暂不做容错处理

return a / b;

}

}

3、导入Junit

4、编写并运行测试类

5、测试结果

三、完善Junit

1、在src下新建source Floder取名为test

2、自动添加测试方法

posted on 2018-03-22 19:38  略略li  阅读(130)  评论(0编辑  收藏  举报