lundi 17 février 2020

Have my Spring test slice scan a single class instead of the whole package

I was asked to create integration tests for an existing SpringBoot project, whose organisation is not as modular as I would prefer. For example, there is a package yielding all repositories associated with all services. This became a problem for me when I was attempting to create a @WebMvcTest test slice, because when I use @ComponentScan to read my target classes it ends up scanning all other unnecessary ones that share the same package.

Since changing the project structure is not really a decision I can make on my own, my question is whether it is possible to have my test scan pick a specific class and disregard all others within the same package?

Thank you for your attention

Aucun commentaire:

Enregistrer un commentaire