It would seem that ActiveProfiles isn't detected when on a SpringBootApplication when run as part of bootTestRun

In src/test/java


import org.springframework.test.context.ActiveProfiles;

@ActiveProfiles("generate-schema")
public class RunGenerateSchema {

    public static void main(String[] args) {
        SpringApplication.from(GenerateSchema::main).with(ContainersConfiguration.class).run(args);;
    }
}

output:

16:30:59.051 [main] INFO  c.elsevier.titan.deca.GenerateSchema - No active profile set, falling back to 1 default profile: "default"

Would be very useful if profiles could be set, without having to override args.

this issue https://github.com/spring-projects/spring-boot/issues/40620 makes sense in a non-test environment, but for test would be handy

Comment From: snicoll

Please review the Javadoc of ActiveProfiles. This is a framework concept and to be used on a test class (the above isn't).

If you want to set a profile, you can do so in your main class using withAdditionalProfiles.