Hi all, this could be a naive question. I use spri...
# help
t
Hi all, this could be a naive question. I use spring boot and use wire mock for my integration tests. I want to ask what is more recommended for my case, is it
@EnableWireMock
for use with Spring Boot or
@WireMockTest
for use with JUnit 5. Thank you very much in advance!
t
Hi Thuy, it’s the first of these if you’re also using
@SpringBootTest
. All works with JUnit 5. Use
@WireMockTest
if you’re using JUnit 5 with something other than Spring.
i
Hi Thuy, Depends on what you're trying to accomplish. As long as you're using the jUnit 5 Runner, you can use either. IMHO the @EnableWireMock annotation is easier to start with, although the @WireMockTest seems to be easier to use when you need to do some less conventional stuff, but either method can do everything. When you need to use a different test runner, e.g. Cucumber runner, then @EnableWireMock is not an option.
t
Good point about Cucumber, although we should aim to fix that in future I think. I would still strongly recommend using the @EnableWireMock approach if you can because it means you can randomize the port numbers easily and thus be able to run tests in parallel and avoid collisions on shared CI runners etc.
👍 2
i
@EnableWireMock is definitely the way to go. Although the documentation can be a bit challenging. I’m making notes and see if I can find some time I can ‘donate’ to the project to propose some updates.
🙏 1
t
That would be much appreciated 👍
t
Thank you all for your detailed answer. I understand it now! Much appreciated!🙏