I won’t use Wiremock with Spring Boot anymore for smaller simpler services.
If you are not a medium member, use the link here to access the content for free.
Spring and Spring boot is my day to day tech as part of my present organisation, along with it unit/ integration testing is something which we all do for maintaining the code quality and code coverage.
Recently I was just writing few unit tests in my code, used @SpringBootTest
for the tests.
The code was nothing more than consuming the downstream endpoints using the RestTemplate
class - very straightforward. Generally teams(including mine) would make use of a mock downstream server(wiremock or something custom) to satisfy the availability of the mock endpoints during the unit/ integration test run.
So I came up with an idea of creating an endpoint corresponding to the downstream in the test package itself by creating a @RestController
class in the test package.
I would rather name the tests here as Implementation tests like a boundary between integration and unit tests, a combination of both.
Code & Config
The example for this POC is here.
It is very easy codebase to explore with & you will easily be able to get the idea about it.