简体   繁体   English

如何使用WireMock模拟类?

[英]How to simulate a class using WireMock?

I have a class AMSClient, which I want to simulate using WireMock. 我有一个类AMSClient,我想使用WireMock进行模拟。 I have seen some examples but I couldn't understand them, as they are using port numbers. 我已经看到了一些示例,但我听不懂,因为它们使用的是端口号。 Can any one tell me how to simulate a class using WireMock. 谁能告诉我如何使用WireMock模拟类。

WireMock isn't an object mocking tool. WireMock不是对象模拟工具。 If you're looking to mock a class or interface I'd suggest looking at Mockito. 如果您想模拟一个类或接口,我建议您看一下Mockito。

However, if the class/interface in question wraps HTTP calls to another service, then WireMock can help by mimicking the HTTP responses from the service. 但是,如果有问题的类/接口将HTTP调用包装到另一个服务,则WireMock可以通过模仿来自该服务的HTTP响应来提供帮助。

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

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