failsafe不适用于Wiremock集成测试

问题描述 投票:0回答:1

我正在使用带有单元测试和集成测试的简单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());
    }
}

您能帮我吗?最好的问候

integration-testing wiremock maven-failsafe-plugin
1个回答
0
投票

删除了junit依赖关系后,我已经解决了问题:

<dependency>
  <groupId>org.junit.jupiter</groupId>
  <artifactId>junit-jupiter-engine</artifactId>
  <version>5.5.2</version>
  <scope>test</scope>
</dependency>

Thks!

© www.soinside.com 2019 - 2024. All rights reserved.