i have a test automation project that i use Rest Assured. On my tests, i use wiremock for external api calls. I don't have a problem when I run the tests one by one. But when i run the tests in parallel, wiremock cannot match requests on time. After a few seconds, I see that it is matched, but my requests are already timeout.
I did an experiment on a test.(i use testng)
@Test(invocationCount = 10, threadPoolSize = 10)
this annotation runs a test in parallel 10 times. if i run a test 10 times in parallel, Wiremock lags in matching requests. if i run a test 2 or 3 times in parallel, i don't have a problem.
My stubs are dynamic. There can not be any conflict. There is a sample (i write kotlin)
val id = randomId() //this method create random id
val token = randomToken() // this method create random token
stubGetSpend(id, token)
fun stubGetSpend(id: String, token: String): StubMapping {
return stubFor(
WireMock.get(urlEqualTo("/$id/insights?access_token=$token&fields=spend"))
.willReturn(
aResponse()
.withStatus(HttpStatus.SC_OK)
.withHeader("Content-Type", "application/json")
)
)
}