I have an extremely basic SpringBootTest that I am trying to run (the contextLoads()) test.
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
@SpringBootTest
@ActiveProfiles("test")
public class ApplicationTest {
@Test
void contextLoads() {
}
}
I have a config file application-test.yml
under src/test/resources/
with some basic configuration that I'd like to use to test my application with. However even with the simple test above the context isn't loading. I'm using IntelliJ to run my tests - and when I run the unit test with Maven the test just is in a running state but it seems like it's frozen loading the context. The only thing I see is
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.1.RELEASE)
and that it says "Running tests..." and it doesn't resolve. I'm not exactly sure what's wrong here. I've noticed when I remove the @ActiveProfiles
annotation that the test fails to run and throws back an exception Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class
where it looks like it's trying to get load my actual configuration file and it' cant because I haven't set environment variables that I use in the config file. So How can I get SpringBootTest to pick up on the application-test.yml
and proceed with the test?