Reputation: 183
I did writer a persistent class SOAPLoanCalculator and have two methods there. Should I have instead two classes write few smaller classes.
In the SOAPLoanCalculatorTest I do not understand how to write test for the loan calculator. I think there are some specific methods I should use. My conclusion is that after word "stub." I have few options I can choose.
Can you give me advice how I should work on the Test Class (how to test loan calculator?). You may give me just idea for example how to call MonthlyPayment method and receive answer back. With the rest I should be able to do the work.
public class SOAPLoanCalculator {
public double monthlyPayment(double principal, double interest, double period){
double mPayment = (principal * interest / 1200) / (1 - Math.pow( 1 / ( 1 + interest / 1200), period) );
return mPayment;
}
public double totalInterestPayments(double principal, double interest, double period) {
double periodicInterest = interest / period;
double interestPayment = periodicInterest * -principal * Math.pow((1 + periodicInterest), period) / (1 - Math.pow((1 + periodicInterest), period));
double totalInterestPayment = (interestPayment * period) - principal;
return totalInterestPayment;
}
}
import ndnu.wc.SOAPLoanCalculator;
import ndnu.wc.SOAPLoanCalculatorStub;
public class SOAPLoanCalculatorTest {
public static void main(String[] args) {
SOAPLoanCalculatorStub stub = new SOAPLoanCalculatorStub();
stub.
}
}
Upvotes: 1
Views: 166
Reputation: 397
You should utilize a standard testing framework such as JUnit to test your Web Services. You could reference http://www.drdobbs.com/web-development/unit-testing-web-services/211201695 to see how to create test cases.
If you would like to utilize some testing tools for JUnit, you could consider SoapUI. Here is the example at http://www.soapui.org/Test-Automation/integrating-with-junit.html
Upvotes: 1