So, as of late, I haven't found any solution similar to the @PostConstruct
one.
In the end, here's how I made it work without inheritance or @BeforeEach
setups:
@SpyBean
annotations with a @MockitoSpyBean
one inside my custom IntegrationTest
annotation (see: documentation).data.sql
file with inserts, located in the src/test/resources
folder. I no longer need to spy on a repository.org.wiremock.integrations:wiremock-spring-boot
This is what the custom IntegrationTest
annotation looks like:
@Retention(RetentionPolicy.RUNTIME)
@SpringBootTest(classes = SpringSecurityTestConfig.class)
@ActiveProfiles("test")
@Sql(scripts = "classpath:sql/clearTables.sql", executionPhase = ExecutionPhase.AFTER_TEST_METHOD)
@AutoConfigureMockMvc
@EnableWireMock({
@ConfigureWireMock(name = "localazy-client", baseUrlProperties = "i18n.localazy.cdnUrl", filesUnderClasspath = "wiremock/localazy-client")
})
@MockitoSpyBean(types = {JavaMailSender.class, LocalazyService.class})
public @interface IntegrationTest {
}
Using Wiremock is a bit heavier than I would have liked, and I might lose a few seconds when running tests individually, but it's a compromise I can accept.
I don't need the IntegrationTestConfig
configuration class anymore, as it's now empty.