I have a custom library (a starter) created with SpringBoot. So, it doesn't have main method or @SpringBootApplication
annotated class.
I want to test this starter functionality with JUnit. I have created a class in src/test
(TestApplication
) to be a launcher.
@SpringBootTest
@ContextConfiguration(classes = TestApplication.class)
@RunWith(SpringRunner.class)
public class SettingsTest {
@Autowired
private MyService myService;
@Test
public void testSettingsLoad(){
//do smth
}
}
@SpringBootApplication
public class TestApplication {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
}
However, TestApplication
main
is not invoked and application context is not raised correctly.
I've tryied without @RunWith
annotation (no Spring context at all) and with adding class directly to @SpringBootTest
annotation (also ignored).
I've read this post, but it wasn't really helpful.
Any ideas appreciated.