标签:Stub org ring googl ack generate pac void ati
1、去官网下载并启动:
2、引入Pom依赖:
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.5.1</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>25.1-jre</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.9.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.9.5</version>
</dependency>
3、编写客户端设置请求与响应:
package wiremock;
import com.github.tomakehurst.wiremock.client.WireMock;
public class WireMockClient {
public static void main(String[] args) {
// TODO Auto-generated method stub
WireMock.configureFor(8090);
WireMock.removeAllMappings();
WireMock.stubFor(
WireMock.get(WireMock.urlPathEqualTo("/order/1")).
willReturn(WireMock.aResponse().
withBody("{\"id\":1,\"name\":\"cqu2010\"}").withStatus(200))); //伪造测试桩
}
}
4、测试:
标签:Stub org ring googl ack generate pac void ati
原文地址:https://www.cnblogs.com/kibana/p/9192976.html