I’m creating a new Spring-Boot application with Spring Cloud API Gateway (MVC).
The purpose is to create a gateway for external requests to backend services.
Unit Testing
In terms of a strategy for unit testing, should I write unit tests to validate the beans that should appear in the application context?
E2E Tests
I’m also going to be writing integration tests for the gateway routes. Does it make sense to annotate the test classes with @SpringBootTest
or should I test a configuration class that only includes the beans I need for the test? E.g. @Import(RouteConfigurationClass.class)
and a separate classfile with @TestConfiguration
.
Related documentation
https://docs.spring.io/spring-boot/reference/testing/spring-boot-applications.html
https://howtodoinjava.com/spring-boot2/testing/springboot-test-configuration/
I’ve read the docs, but don’t understand the recommended approach for this situation.