how to run/turn off selective tests based on profiles in spring boot

It works also with active profiles - there is a property value containing active profiles:

Test only active with specific profile:

@IfProfileValue(name = "spring.profiles.active", values = {"specific"})

Since i have tests that should NOT run if specific profile is active i added this to those tests:

@ActiveProfiles(profiles = {"default"})

It does not work with @IfProfileValue and "default" and i also didn't found any "run if specific profile is not active.


You would want to use the @IfProfileValue annotation. Unfortunately it doesn't work directly on the active profiles but it can read a property so if you only define a specific property within the profiles that you want to run the test on then you can use that annotation on that specific property.

http://docs.spring.io/spring/docs/current/spring-framework-reference/html/integration-testing.html#integration-testing-annotations-junit