我正在使用一个简单的带有单元和集成测试的Spring应用程序。我试图使用wiremck进行集成测试,但是当我执行mvn故障安全:集成测试
目标时,结果是测试运行: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>
和wiretck测试:
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());
}
}
你能帮我吗?最好的问候
当我删除junit依赖时,我已经解决了这个问题:
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
谢谢!