If you work with Microservices, you surely faced the situation in which some of your system processes only make sense after the information flows through several microservices. For instance, if you’re implementing an Event-Driven architecture, you certainly want to verify your Business Processes when events are propagated and other parts react upon them. There are several frameworks you can use for that but, for its simplicity and perfect matching with Business requirements, Cucumber is a great option. Let’s get into the process of writing end-to-end scenarios using Cucumber.
There are different ways to test your Controller (Web or API Layer) classes in Spring Boot, some provide support to write pure Unit Tests and some others are more intended to be used for Integration Tests. Within this post, I’ll cover the main three test approaches available for Spring: using MockMVC in standalone mode, MockMVC together with SpringRunner, and using SpringBootTest.