I have some integration tests that create/delete entries in my database. The problem is if I run the tests with
spring.profiles.active=prod
my production database gets deleted (as the tests clear the database). Is there any way to prevent tests from running on this specific spring profile?
I have seen this thread: How to prevent running tests when specific spring profile is active? but there was no useful answer.
Thank you
I was able to resolve the problem following this comment: https://stackoverflow.com/a/32892291/8679100.
The solution is not perfect, as I need to verify if the prod profile is active in @BeforeAll
and @AfterAll
, but it does work. Furthermore,
System.getProperty("spring.profiles.active", "");
didn't actually work, but
Arrays.stream(environment.getActiveProfiles()).anyMatch(env -> (env.equalsIgnoreCase("prod")))
did