Until Spring Modulith 2.0.0 the following test setup is working fine.
@Import(TestcontainersConfiguration.class)
@AutoConfigureMockMvc
public abstract class AbstractIntegrationTest {
@Autowired
protected MockMvcTester mockMvcTester;
}
@ApplicationModuleTest(
webEnvironment = RANDOM_PORT,
mode = DIRECT_DEPENDENCIES,
extraIncludes = {"config", "users"})
class AdminBooksControllerTests extends AbstractIntegrationTest {
//tests
}
But when I upgrade to Spring Modulith 2.0.1 or 2.0.2, the TestcontainersConfiguration is not considered and failed with the following error:
WARN org.springframework.boot.web.server.servlet.context.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'com.sivalabs.bookstore.common.TestcontainersConfiguration' available
I can work around this by simply adding @Import(TestcontainersConfiguration.class) to all the tests like AdminBooksControllerTests. But instead of duplicating the configuration, I would prefer to have it in parent base test and work as it used to in Spring Modulith 2.0.0.
PS: Reproducer repo https://github.com/sivaprasadreddy/bookstore
More context:
The TestcontainersConfiguration and AbstractIntegrationTest are in common package com.sivalabs.bookstore.common and AdminBooksControllerTests is in com.sivalabs.bookstore.admin.web package then it is failing. However, if I move TestcontainersConfiguration and AbstractIntegrationTest to the base package com.sivalabs.bookstore then its working fine.
Until Spring Modulith 2.0.0 the following test setup is working fine.
But when I upgrade to Spring Modulith
2.0.1or2.0.2, theTestcontainersConfigurationis not considered and failed with the following error:I can work around this by simply adding
@Import(TestcontainersConfiguration.class)to all the tests likeAdminBooksControllerTests. But instead of duplicating the configuration, I would prefer to have it in parent base test and work as it used to in Spring Modulith 2.0.0.PS: Reproducer repo https://github.com/sivaprasadreddy/bookstore
More context:
The
TestcontainersConfigurationandAbstractIntegrationTestare incommonpackagecom.sivalabs.bookstore.commonandAdminBooksControllerTestsis incom.sivalabs.bookstore.admin.webpackage then it is failing. However, if I moveTestcontainersConfigurationandAbstractIntegrationTestto the base packagecom.sivalabs.bookstorethen its working fine.