I have an application spring-bootfor which I am writing IT tests.
Data for tests taken from application-dev.propertieswhen I activate the profiledev
Here is what I have for the 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 setting up the profile "dev", "qa". by default it should not work.
Is it possible to get this subtle control when testing spring boot?
source
share