What's the best way of excluding javax.servlet.Filter
s from specific @WebMvcTest
s in a granular way when they're defined via @Bean
instead of @Component
?
More information: @WebMvcTest
excludeFilters
works fine for excluding beans defined via component scanning (i.e. @Component
). However, excluding beans defined via @Bean
from specific @WebMvcTest
s is not as easy. Instead of excluding those beans on my test classes I have to make sure that they're not picked up by the slicing and then include them manually. One way of doing this is to group beans into different @Configuration
classes based on how I will need to include or exclude them in the tests. However, I'm starting to compromise project structure, by creating unneeded @Configuration
classes that maybe don't make a lot of sense, due to testing framework limitations.
What about mocking? In some situations, like the one described in the top of this question, mocking is not appropriate. Mocking a javax.servlet.Filter
doesn't make a lot of sense since you need to call the rest of the chain filter.
Aucun commentaire:
Enregistrer un commentaire