I'm using Spring Boot 1.5.9 and we have a micro service that connects with another micro services.
For integration test and development (the developer computer) I would like to mock/stub the rest calls made for another micro services. For unit/integration tests this question is already answered many times: WireMock, MockBean and MockRestServiceServer are good tools. But for development I'm trying to figure out the best approach.
Why? Is a problem to start each microservice that the actual microservice depends. So the idea is make the microservice independent and start without any additional server running in the developer's machine or on other place. So, a simple `mvn spring-boot run' would be enough to start my microservice and work without any concern about another microservices.
So, my question is: what the recommended aproach for mock/stub rest calls in development? Wiremock is a good approach in this case too?
I have two profiles in src/main/java/resources/
: the 'default' (application.properties, that's used for another environment) and the 'dev' (application-dev.properties, used for development).
In my tests (src/test/java/resources/
) I have only one application.properties, that is basic a copy of application-dev.properties.
I already try to use Wiremock for integration tests and works well. But I would not like to use it for development too because I don't like so much the idea to introduce a dependency only used for development in my JAR. My intention is use the same strategy to integration test and development.
So, what's the options?
So you want to start your microservice locally e.g. for manual testing, but you do not want to start all the other microservices it depends on.
Teams do one of the following:
Which of those works best for you depends on your environment, and what exactly the other microserivce dependencies provides as functionality. You cannot expect any of those to be a silver bullet that is best for all teams and all situations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With