I have one instance of wiremock that is used across multiple test classes, It has worked fine until recently, when used to test async methods, when the test classes are ran singly, tests pass but when the entire tests are ran(mvn test), some of the async class tests fail with ConditionTimeOut error. The verify is failing because, I presume, the wiremock server was not done when the verify was called and the awaitility library is waiting for it. Just my understanding based on this links --> https://github.com/tomakehurst/wiremock/issues/565
https://github.com/tomakehurst/wiremock/issues/574
here is my wiremock class def :
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureWireMock(port = 9099)
public class WireMockTest {
@Autowired
public wireMockClassA wireMockClassA;
@Autowired
public wireMockClassB wireMockClassB;
//other definitions here and more wiremock class...
}
here is an example test async class:
public class SaleWireMockTest extends WireMockTest {
@Test
void call_sale_endpoint_and_return_200() {
wireMockClassA.callSaleEndpoint(PATH, request, HttpStatus.OK);
makeAsyncCall();
await().atMost(1, TimeUnit.SECONDS).untilAsserted(() ->
wireMockClassA.verify(1, request));
}
//more test methods here....
}
stack:
- java 14
- wiremock 2.26.2
- Spring boot 2.3.2.RELEASE