對象:
sumofthey裡面的M方法:
1 public static double M(double a,double x,double n){
2 try{
3 double M=(double) (a*(1+x)*(-1+Math.pow(1+x,n))/x);
4 return M;
5 }
6 catch(Exception e){
7
8 return 0;}
9 }
測試:
1 public void testM() {
2 double M=sumofthey.M(3600,0.15,35);
3 assertEquals(3648044.0, M, 1.0);
4 }
結果:

手動測試:
1.輸入字母
2.過大年限
3.過大利率
4.不輸入任何數,點選跳出福利彩蛋
總結:
對于double類型的測試,誤差範圍越小,測試越精确