79596963

Date: 2025-04-28 17:03:22
Score: 1
Natty:
Report link

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:

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.

Reasons:
  • Blacklisted phrase (1.5): any solution
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: M4veR1K