I have a Java web application with spring boot
When running the test, I need to exclude some Java configuration files:
Test configuration (must be enabled when starting the test):
@TestConfiguration
@PropertySource("classpath:otp-test.properties")
public class TestOTPConfig { }
Production configuration (must be excluded when starting the test):
@Configuration
@PropertySource("classpath:otp.properties")
public class OTPConfig { }
Testing class (with explicit configuration class):
@RunWith(SpringRunner.class)
@SpringBootTest(classes = TestAMCApplicationConfig.class)
public class AuthUserServiceTest { .... }
Test Configuration:
@TestConfiguration
@Import({ TestDataSourceConfig.class, TestMailConfiguration.class, TestOTPConfig.class })
@TestPropertySource("classpath:amc-test.properties")
public class TestAMCApplicationConfig extends AMCApplicationConfig { }
There is also a class:
@SpringBootApplication
public class AMCApplication { }
When a test is used OTPConfig, but I need TestOTPConfig...
How can i do this?
source
share