I have a Java web app with spring boot
When run test I need to exclude some Java config files:
Test config (need to include when test run):
@TestConfiguration
@PropertySource("classpath:otp-test.properties")
public class TestOTPConfig { }
Production config (need to exclude when test run):
@Configuration
@PropertySource("classpath:otp.properties")
public class OTPConfig { }
Test class (with explicit config class):
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestAMCApplicationConfig.class)
public class AuthUserServiceTest { .... }
Test config:
@TestConfiguration
@Import({ TestDataSourceConfig.class, TestMailConfiguration.class, TestOTPConfig.class })
@TestPropertySource("classpath:amc-test.properties")
public class TestAMCApplicationConfig extends AMCApplicationConfig { }
Also have class:
@SpringBootApplication
public class AMCApplication { }
When test is running OTPConfig
used, but I need TestOTPConfig
...
How can I do it?