标签:
说明:之前用C语言写代码,现用java写代码。
场景分析,期待的返回值以及运行结果如下表:
注释:预期结果0.0,表示输入数据有误。即得不到正确的结果
测试模块
|
测试输入
|
预期结果
|
运行结果
|
bug跟踪
|
单利计算 获得利息 |
“100”,”2”,”1” |
102.0 |
正确 |
|
“0”,”2”,”1” |
0.0 |
正确 |
|
|
“0”,”dsaf”,”1” |
0.0 |
正确 |
|
|
“0”,”-100”,”1” |
0.0 |
正确 |
|
|
单利计算 获得利息 |
“100”,”2”,”1” |
102.01 |
正确 |
|
“0”,”dsaf”,”1” |
0.0 |
正确 |
|
|
“0”,”2”,”1” |
0.0 |
正确 |
|
|
“0”,”-100”,”1” |
0.0 |
正确 |
|
|
计算本金(按复利) |
“106”,”2”,”1” |
103.91 |
正确 |
|
“0”,”dsaf”,”1” |
0.0 |
正确 |
|
|
“0”,”2”,”1” |
0.0 |
正确 |
|
|
“0”,”-100”,”1” |
0.0 |
正确 |
|
其他计算功能测试与上述相似。
运行测试结果如下(部分):
测试程序代码如下(部分):
//用于测试单利计算获得利息 public void testSimpleInteres() { SimpleInteres s = new SimpleInteres(); Assert.assertEquals(102.0, s.getResult("100", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("0", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("asdf", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("100", "-1", "2"),0.1); } //用于测试复利计算获得利息 public void testCompoundInterest() { CompoundInterest s = new CompoundInterest(); Assert.assertEquals(102.01, s.getResult("100", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("0", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("asdf", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("100", "-1", "2"),0.1); } //用于测试计算本金(按复利) public void testGetPrincipal() { GetPrincipal s = new GetPrincipal(); Assert.assertEquals(103.91, s.getResult("106", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("0", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("asdf", "1", "2"),0.1); Assert.assertEquals(0.0, s.getResult("100", "-1", "2"),0.1); }
标签:
原文地址:http://www.cnblogs.com/yanwensheng/p/5335158.html