Test module |
Data |
Forecast results |
Input data |
Error results |
Error handling |
1. Principal and interest |
Principal blank |
|
|
|
|
|
Interest rate blank |
|
|
|
|
|
Number of years blank |
|
|
|
|
|
The principal is 0 |
|
|
|
|
|
Interest rate is 0 |
|
|
|
|
|
The number of years is 0 |
|
|
|
|
|
Interest rate greater than 1 |
|
|
|
|
|
The principal is infinitely large |
|
|
|
|
2. Principal |
Principal and interest is 0 |
|
|
|
|
|
Interest rate is 0 |
|
|
|
|
|
The number of years is 0 |
|
|
|
|
|
The principal interest is very large |
|
|
|
|
1 Public DoubleCalculatea (DoubleYears2,intN2,DoublePrincipal2,Doublerate2) {2 DoubleAmount2 = 0;3 while(Years2 <=n2) {4 /*amount = Principal * MATH.POW (1 + rate, year);5 Output + = string.valueof (year) + "\ T" + currencyformatter.format (amount) + "\ n";6 Year = year + 1;*/7Amount2 = Principal2 * MATH.POW (1 +Rate2, years2);8 9 TenYears2 = years2 + 1; One } A returnAmount2; -}
The previous code has not been marshaled, which is the function of the principal and interest package, but not when testing
1 Public class atest {23 @Test4public void Test () {5 double a=new fuli1 (). Calculatea (1, 3, 10000, 0.03); 6 Assertequals (10927.27, a); 7 }89 }
Reason for error:Assertequals supports Boolean,long,int and so on Java primitivetype variables.
1 Public classatest {2 3 4 @Test5 Public voidTest () {6 DoubleA=NewFuli1 (). Calculatea (1, 3, 10000, 0.03);7 Booleanflag=0.0==a-10927.27;8Assertequals (true, flag);9}
Not very familiar with testing, looking for other resources in learning
There are other predictions that are being tested, which are only part of the
Second, summary
For this quiz, I think my previous code is a mess, all are squeezed together so that I can not understand their own ideas, through the test, I am slowly learning to make up a clear structure of the program
Test of compound Interest Calculation 1