我正在使用带有单元测试和集成测试的简单Spring应用程序。
我正在尝试使用Wiremock进行集成测试,但是当我执行mvn failsafe:integration-test
目标时,结果是Tests run: 0
。
我的pom.xml配置是:
...
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
...
<build>
..
<plugins>
..
<plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<includes>
<include>**/*ITTest</include>
</includes>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
..
</plugins>
..
</build>
以及Wiremock测试:
public class WireMockITTest {
private static final String ENDPOINT = "http://localhost:8089/sample/";
private RestTemplate restTemplate = new RestTemplate();
@Rule
public WireMockRule wireMockRule = new WireMockRule(8089);
@Test
public void shouldGetSuccess() throws URISyntaxException {
URI getEndpoint = new URI(ENDPOINT + 1234);
ResponseEntity<Sample> responseEntity = restTemplate
.getForEntity(getEndpoint, Sample.class);
verify(getRequestedFor(urlEqualTo("/sample/" + 1234)));
assertTrue(responseEntity.getStatusCode().is2xxSuccessful());
}
}
你能帮我吗? 最好的问候
答案 0 :(得分:0)
当我删除junit依赖项时,我已经解决了这个问题:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
谢谢!