0

I'm writing an integration testing framework, and in my parent test class I have the following:

@ContextConfiguration(loader = AnnotationConfigContextLoader.class)
public abstract class IntegrationTestParent extends AbstractTestNGSpringContextTests {

    ...

    @Configuration
    @EnableAutoConfiguration
    @ComponentScan("redacted")
    public static class AutomationTestConfig {
    }
}

Which allows me a great deal of flexibility, however, I've noticed that my custom banner.txt file is no longer printed out, nor is my application.properties file (which sets spring.output.ansi.enabled=ALWAYS and some maven filtered application variables) being read.

In addition to some really leet figlet generated ascii art, it printed out a lot of convenient debug information about the JVM and various system and environment properties so I had a really good idea about the remote environments (a la Jenkins and Bamboo or anyone's arbitrary laptop) they were running on.

Is there a way to get this to behavior in addition to @ContextConfiguration(loader = AnnotationConfigContextLoader.class)?

Niko
  • 4,158
  • 9
  • 46
  • 85

1 Answers1

0

I've found an intermediate solution. I will call it intermediate, because I get the behavior I want (annotation based contexts that are loadable in down stream projects where I have additional configurations and beans, etc) but I didn't use the AnnotationConfigContextLoader class.

I swapped it for the SpringApplicationContextLoader. Per the javadoc:

A ContextLoader that can be used to test Spring Boot applications (those that normally startup using SpringApplication). Can be used to test non-web features (like a repository layer) or start an fully-configured embedded servlet container. Use @WebIntegrationTest (or @IntegrationTest with @WebAppConfiguration) to indicate that you want to use a real servlet container or @WebAppConfiguration alone to use a MockServletContext.

If @ActiveProfiles are provided in the test class they will be used to create the application context.

Based on the first few sentences, this was essentially what I was looking for.

Niko
  • 4,158
  • 9
  • 46
  • 85