天天看點

利率計算v4.0--測試--軟體工程

利率計算v4.0--測試      
package Test;

import Model.Interest;
import Service.CompoundInterestService;
import Service.OrInterestService;
import Service.PrincipalService;
import Service.SingleInterestService;
import org.junit.Test;

/**
 * Created by pc on 2016/3/28.
 */
public class TestInterest {
    @Test
    public void testInterest(){
        Interest interest = new Interest(0.5,1000,10);
        System.out.println(interest.getInterest() +" "+ interest.getPrincipal() +" "+ interest.getYear());
    }

    @Test
    public void testOrInterest(){
        Interest interest = new Interest(0.5,1000,10);
        System.out.println(new OrInterestService().orInterest("compound" , interest));
        System.out.println(new OrInterestService().orInterest("single" , interest));
    }

    @Test
    public void testCompoundInterest(){
        Interest interest = new Interest(0.5,1000,10);
        System.out.println(new CompoundInterestService().calculate(interest));
    }

    @Test
    public void testSingleInterest(){
        Interest interest = new Interest(0.5,1000,10);
        System.out.println(new SingleInterestService().calculate(interest));
    }

    @Test
    public void testPrincipal(){
        Interest interest = new Interest();
        interest.setAmount(1000);
        interest.setYear(10);
        interest.setInterest(0.5);
        System.out.println(new PrincipalService().calculate(interest));
    }

    @Test
    public void testYear(){
        Interest interest = new Interest();
        interest.setAmount(1000);
        interest.setPrincipal(10000);
        interest.setInterest(0.5);
        System.out.println(new PrincipalService().calculate(interest));
    }

    @Test
    public void testLong(){
        Interest interest = new Interest();
        interest.setAmount(1000000000);
        interest.setPrincipal(1000000000);
        interest.setInterest(0.000000000001);
        System.out.println(new PrincipalService().calculate(interest));
    }

    @Test
    public void test_01(){
        Interest interest = new Interest();
        interest.setAmount(1);
        interest.setPrincipal(1);
        interest.setInterest(1);
        System.out.println(new PrincipalService().calculate(interest));
    }

}      
<script type="text/javascript">
      function check(form){
        if (document.forms.compoundInterest.principal.value == ""){
          alert("請輸入本金 !");
          document.forms.compoundInterest.principal.focus();
          return false;
        }
        if (document.forms.compoundInterest.interestRate.value == ""){
          alert("請輸入利率 !");
          document.forms.compoundInterest.interestRate.focus();
          return false;
        }
        if (document.forms.compoundInterest.year.value == ""){
          alert("請輸入年份 !");
          document.forms.compoundInterest.year.focus();
          return false;
        }
      }
    </script>      
測試子產品 測試資料 終值  運作結果  bug跟蹤

輸入是否

正确

本金:(1000);

年限:(10);

利息:(0.5);

 (0.5,1000,10)  √

單利/複利

選擇

插入 字元串 選擇
"compound" /"single"      

複利

計算

 本金:(1000);  57665.04
單利  本金:(1000);  15000.00   √
本金
本利之和:(1000);      
年限:(10);      
利息: (0.5);      
17.34
年限
本利之和:(1000);      
本金:(10000);      
利息: (0.5);      
1000.00 

 算法

有誤

測試

數值

本利之和:(1000000000);      
本金:(1000000000);      
利息: (0.000000000001);      
1000000000.00 

 超出類型

上限

本利之和:(1);      
本金:(1);      
利息: (1);      
1.00

利息應為

浮點型 

插入 空 資料
送出      

提出警告

并且不能送出資料

上一篇: 繪圖
下一篇: 詞法分析