I have a spring-boot
application for which I am writing IT tests.
The data for the tests comes from application-dev.properties
when I activate dev
profile
Here is what I have for tests:
@RunWith(SpringRunner.class)
@SpringBootTest
@WebAppConfiguration
public class ApplicationTests {
@Autowired
Environment env;
@Test
public void contextLoads() {
System.out.println(Arrays.toString((env.getActiveProfiles())));
}
}
ServiceITTest
public class ServiceITTest extends ApplicationTests {
@value
String username;
@value
String address;
@Autowired
MyService myService;
@Test
public void check_for_valid_username_address(){
myService.validate(username,address);
}
}
I want the above test to run only when I set the profile of "dev","qa". by default, it should not run.
Is it possible to get that fine control in spring boot testing?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…