利率计算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);

年限:(10);

利息:(0.5);

 57665.04

 √

单利

计算

 本金:(1000);

年限:(10);

利息:(0.5);

 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  

利息应为

浮点型 

测试

数值

插入 空 数据
提交

提出警告

并且不能提交数据

 
原文地址:https://www.cnblogs.com/caishun/p/5336223.html