Wiremock: Test interference with repeated stop and start.

Created on 5 Jul 2017  路  4Comments  路  Source: tomakehurst/wiremock

We have some tests using WireMockRule that fail intermittently. The we're using @Rule rather than @ClassRule which means the underlying jetty server is being started and stopped between each test method. I think that the lack of a stop timeout on jetty means that there is some interference between tests.

There's an example test that illustrates the issue.

With the current timeout this test has always (for me at least) thrown an exception. When I set a stop timeout of 1 second on the jetty server the test can complete.

Maybe bug

Most helpful comment

Same problem here, the following setting fixed it for me:

new WireMockServer(WireMockConfiguration.options() .jettyStopTimeout(10000L));

All 4 comments

I think this is related to #563 and #589 . With the timeout set there are no more warnings about not being able to stop threads.

Same problem here, the following setting fixed it for me:

new WireMockServer(WireMockConfiguration.options() .jettyStopTimeout(10000L));

We're seeing this issue too. Basically it blows up the unit tests when running in a particular order and the port is reused.

A little more details, wiremock must relase ports cleanly due to caching of contexts.

https://docs.spring.io/spring/docs/current/spring-framework-reference/testing.html#testing-ctx-management

We're using a Junit 5 extension to set up our mocks, which injects concrete network addresses into the spring context, so these should not be changed (i.e. no port change).

Was this page helpful?
0 / 5 - 0 ratings