It would seem that ActiveProfiles isn't detected when on a SpringBootApplication maybe this is intentional, but I guess I was expecting it to be respected on a configuration.

package org.example.bugpropertysource;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("test")
@SpringBootApplication
public class BugPropertySourceApplication {
}
# application-test.properties
spring.main.banner-mode=off
15:35:14.637 [Test worker] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [org.example.bugpropertysource.BugPropertySourceApplicationTests]: BugPropertySourceApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
15:35:14.709 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Found @SpringBootConfiguration org.example.bugpropertysource.BugPropertySourceApplication for test class org.example.bugpropertysource.BugPropertySourceApplicationTests

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v3.2.5)

2024-05-03T15:35:15.013-04:00  INFO 2069502 --- [bug-property-source] [    Test worker] o.e.b.BugPropertySourceApplicationTests  : Starting BugPropertySourceApplicationTests using Java 17.0.8 with PID 2069502 (started by xeno in /home/xeno/IdeaProjects/bug-property-source)
2024-05-03T15:35:15.015-04:00  INFO 2069502 --- [bug-property-source] [    Test worker] o.e.b.BugPropertySourceApplicationTests  : No active profile set, falling back to 1 default profile: "default"
2024-05-03T15:35:15.860-04:00  INFO 2069502 --- [bug-property-source] [    Test worker] o.e.b.BugPropertySourceApplicationTests  : Started BugPropertySourceApplicationTests in 1.042 seconds (process running for 1.819)
OpenJDK 64-Bit Server VM warning: Sharing is only supported for boot loader classes because bootstrap classpath has been appended
> Task :test
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.7/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 2s
4 actionable tasks: 1 executed, 3 up-to-date
3:35:16 PM: Execution finished ':test --tests "org.example.bugpropertysource.BugPropertySourceApplicationTests"'.

bug-property-source.tar.gz

Comment From: wilkinsona

This behavior is govenered by Spring Framework's test framework. The relevant logic can be found in org.springframework.test.context.support.ActiveProfilesUtils and org.springframework.test.context.support.DefaultActiveProfilesResolver. We want Boot's behavior to align with Framework's default behavior so any change to this would have to be made in Framework.