Filters When using
As noted in my article Shift Your Testing Left with Spring Boot Controllers, the aim of writing
WebMvcTests is to verify that Spring annotations are set on the class, and that it actually responds as a controller.
Although it's an integration test, we should try and keep our test slice as thin as possible.
For instance, we may have
Filters running in the background, which may be requiring that we have a
correlation-id sent in each request, which is adding additional complexity in our requests.
Let's say that our test class is being set up with the following annotation:
We'd now be able to tweak this to:
value = MetadataController.class,
type = FilterType.ASSIGNABLE_TYPE,
classes = CorrelationIdFilter.class))
And our tests would no longer be using the