针对调用 Web 服务的方法签名编写 JUnit 测试的最佳方法是什么?
我想要测试的方法有一个局部变量,该变量引用从 Web 服务调用返回的对象。此 Web 服务根据特定用户在网页上的输入返回特定于该用户的信息。它就像一个问题/答案,表单文本字段中给出的答案必须与用户之前提供的答案相匹配,并且现在与他们的帐户绑定。根据他们是否得到正确答案,会发生某些事情。我应该将服务模拟为类上的一个字段,我可以将其设置为返回虚拟服务响应,还是有更好的方法来测试它?谢谢!
The method I want to test has a local variable that references an object returned from a Web service call. This Web service returns information specific to a particular user based upon input from that user on a Web page. It is like a question/answer, where the answer given in a form text field must match the answer provided by the user at an earlier date, and is now tied from their account. There are certain things that happen based upon whether or not they got the answer correct. Should I mock out the service as a field on the class instead, where I can set it to return a dummy service response, or is there a better way to test it? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为你的直觉很好,可以模拟这项服务。
I think your intuition is good on this one, to mock out the service.