:wave: Hello, team! I have written unit tests for ...
# wiremock-java
r
👋 Hello, team! I have written unit tests for 2 controllers using wiremock and now getting following error in test environment "FatalStartup java.lang.RuntimeException: java.io.IOException: Failed to bind to /0.0.0.0:8091" All tests runs fine in local environment but fails in test environment with above error. Any suggestions to fix above issue
l
Hi Have you hardcoded the WireMock port to
8091
? It looks like something in your test environment is already using that port so WireMock can't bind to it. I would recommend configuring WireMock to use a dynamic port number so you are less likely to clash with other things
You can configure WireMock with dynamic ports in the following way
Copy code
wireMockConfig().dynamicPort()
There is also a
.dynamicHttpsPort()