简体   繁体   English

SOAP测试客户端Web服务类

[英]SOAP testing client web service class

I did writer a persistent class SOAPLoanCalculator and have two methods there. 我确实编写了一个持久类SOAPLoanCalculator,并在那里有两个方法。 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. 在SOAPLoanCalculatorTest中,我不了解如何为贷款计算器编写测试。 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. 您可能只是给我一个想法,例如如何调用MonthlyPayment方法并收到答复。 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. }

}

You should utilize a standard testing framework such as JUnit to test your Web Services. 您应该利用诸如JUnit之类的标准测试框架来测试您的Web服务。 You could reference http://www.drdobbs.com/web-development/unit-testing-web-services/211201695 to see how to create test cases. 您可以参考http://www.drdobbs.com/web-development/unit-testing-web-services/211201695以了解如何创建测试用例。

If you would like to utilize some testing tools for JUnit, you could consider SoapUI. 如果您想对JUnit使用某些测试工具,则可以考虑SoapUI。 Here is the example at http://www.soapui.org/Test-Automation/integrating-with-junit.html 这是http://www.soapui.org/Test-Automation/integrating-with-junit.html上的示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM