# 结对编程-单元测试

201421123098 胡丹丹 201421123118 张中结

1.整数四则运算测试

2.分数四则运算测试

3.求最大公约数测试

## 三、测试用例

package JieDui;
import static org.junit.Assert.*;
import org.junit.Test;
public class CalculateTest {
@Test
public void testReduce(){
Calculate cal = new Calculate();
int result = cal.reduce(40,20);
int expected=20;
assertEquals(expected, result);
}

@Test
Calculate cal = new Calculate();
String expected="32778";
assertEquals(expected, result);
}
@Test
public void testSub() {
Calculate cal = new Calculate();
String result = cal.sub(6,3);
String expected="3";
assertEquals(expected, result);

}
@Test
public void testMul() {
Calculate cal = new Calculate();
String result = cal.mul(6,3);
String expected="18";
assertEquals(expected, result);
}
@Test
public void testDiv() {
Calculate cal = new Calculate();
String result = cal.div(5,2);
String expected="5/2";
assertEquals(expected, result);
}
@Test
Calculate cal = new Calculate();
String expected="7/5";
assertEquals(expected, result);
}
@Test
public void testScoreSub() {
Calculate cal = new Calculate();
String result = cal.ScoreSub(4,5,1,5);
String expected="3/5";
assertEquals(expected, result);
}
@Test
public void testScoreMul() {
Calculate cal = new Calculate();
String result = cal.ScoreMul(4,5,1,5);
String expected="4/25";
assertEquals(expected, result);
}
@Test
public void testScoreDiv() {
Calculate cal = new Calculate();
String result = cal.ScoreDiv(4,5,1,2);
String expected="8/5";
assertEquals(expected, result);
}
}

5.覆盖率

6.结对照片

## PSP展示

 PSP2.1 Personal Software Process Stages Time (%) Senior Student(/hour) Time (%)(/hour) · Planning 计划 2 2.5 · Estimate 估计这个任务需要多少时间 0.5 0.5 · Analysis 需求分析 (包括学习新技术) 1 1 · Coding Standard 代码规范 0.5 0.5 · Design 具体设计 1.5 2 · Coding 具体编码 20 24 · Test 测试（自我测试，修改代码，提交修改） 1 1 Reporting 报告 1 1

## 小结

PS:问在隔了一周之后再看之前的代码，是否更能体会到下面这些东西?

(1) 良好的设计

(2) 编码规范

(3) 必要的注释

posted @ 2017-03-29 14:37  网络1414张中结  阅读(161)  评论(1编辑  收藏  举报