利率计算v4.0--测试--软件工程

Posted 20蔡舜

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了利率计算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跟踪

1

 

 

 

 

2

 

 

 

 

 

3

 

 

 

 

       

以上是关于利率计算v4.0--测试--软件工程的主要内容,如果未能解决你的问题,请参考以下文章

复利计算器(软件工程)及Junit测试———郭志豪

利率计算v2.0--web版--软件工程

[软件推荐]快速文件复制工具(Limit Copy) V4.0 绿色版

软件工程实验一 复利计算

复利计算之单元测试

软件工程实验一 复利计算——单元测试