Using @EnabledIf with spring.profiles.active property in Spring Environment within tests

To check the exact value of a property from the Spring Environment, you should use the following approach.

@EnabledIf(expression = "#{environment['spring.profiles.active'] == 'test'}", loadContext = true)

To check which profiles are currently active in the Spring Environment, you should use the following approach.

@EnabledIf(expression = "#{environment.acceptsProfiles('test', 'someotherprofile')}", loadContext = true)