Skip to content

How do I run a test with a toy Spring context populated with generated classes? #70244

Discussion options

You must be logged in to vote

Body

How do I run a test with a toy Spring context populated with generated classes? Code below doesn't work. I can't scan src packages from within the test root. What could I do instead? It's important to scan packages since I need beans Mapstruct generates. I can't declare them as @Beans in the config cause it generates a mapper and a delegate (my mapper is decorated), and I can only retrieve the former with Mappers.getMapper()

@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = CardMapperTest.Config.class)
class CardMapperTest {
// ...
    @Configuration
    @ComponentScan(basePackages = "src/main/java/by/afinny/credit/mapper")
    public static class Config {
    }
}

G…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by NadChel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Programming Help Programming languages, open source, and software development.
1 participant