复利计算单元测试-软件工程

测试模块

测试输入

预期结果

运行结果

bug跟踪

计算终值

(本金,年限,利率,次数)

终值

   

1

(100,5,0.02,0)

110.40808032

 

2

(0,10,3,1)

弹出提示:请输入>0的本金

没有提示,显示0

已改进。弹出提示:请输入>0的本金

 

3

(100,0,3,1)

弹出提示:请输入>0的的年限

没有提示,显示0

已改进。弹出提示:请输入>0的年限

4

 

(10000000,0.02,100000,1)

 弹出提示:输入值太大    没有提示,显示0  

计算本金

(终值,年限,利率,次数) 本金    
1 (134,10,0.03,1) 100  
2 (0,10,3,1) 弹出提示:请输入>0的终值 没有提示,显示0 已改进。弹出提示:请输入>0的本金
3 (100,0,3,1) 弹出提示:请输入>0的的年限 没有提示,显示0 已改进。弹出提示:请输入>0的年限
4 (asd,dsad,asd,1) 弹出提示:请输入数字 没有提示,显示乱码 已改进。弹出提示:请输入正确的数字
         
         
 1 1 package tests;
 2  2 
 3  3 import com.exxample.junit.Fuli;
 4  4 import junit.framework.Assert;
 5  5 import org.junit.Before;
 6  6 import org.junit.Test;
 7  7 
 8  8 /**
 9  9  * Created by lenovo on 2016/3/28.
10 10  */
11 11 public class FuliTest {
12 12           private Fuli fulitext;
13 13 
14 14     @Before
15 15     public void setUp() throws Exception {
16 16          fulitext =new Fuli();
17 17 
18 18     }
19 19 
20 20     @Test          //测试数值期望值相等
21 21     public void testCaMoney() throws Exception {
22 22         double result=fulitext .CaMoney(100,0.02,5);
23 23         Assert.assertEquals(110.40808032,result); 
24 24 
25 25     }
26 26 
27 27     @Test
28 28     public void testCaBMoney() throws Exception {
29 29         double result=fulitext .CaAMoney(100,0.02,10) ;
30 30         Assert.assertEquals(1116.8715419732623,result);
31 31     }
32 32 
33 33     @Test            //测试极限的大小
34 34     public void testCaValue() throws Exception {
35 35              double result=fulitext .CaValue(10000000,0.02,100000);
36 36               Assert.assertTrue(result==0 );
37 37     }
38 38 
39 39 
40 40 
41 41 
42 42 }
43  

 

posted @ 2016-03-30 10:59  19林宇粲  阅读(287)  评论(0编辑  收藏  举报