src/test/java packages and src/main/java packages should match.
I had same issue where
- my
src/main/javapackages were starting with com.comp.example but src/test/javapackages were starting with com.sample.example
Because of this spring boot application was not able to pickup the configuration of the application, which it picks up from @SpringBootApplication class.
So test case should fall under the same packages where @SpringBootApplication in src/main/java is written.