In Gradle you can put
tasks.named('test') { useJUnitPlatform() systemProperty("spring.profiles.active", "test") }
to set your Spring Profile to test for this task.
test