SilentLucidity
SilentLucidity

Reputation: 410

Start services manually when doing a spring boot test

So I have a test class annotated with @SpringBootTest

@SpringBootTest
@Slf4j
public class IntegrationTests {}

This code automatically starts two of classes in my application annotated with @service.
In my integration test I’m testing the spring scheduler to works as expected and the tests passes.

Now I want to write another test that only test one of the two services annotated with @service. The second service I want to enable and disable myself. This is because one of two services uses the springboot @scheduled annotation, which results in unpredictable logic.

So is there a way I can start a @SpringBootTest with the possibility to choose the services I need?

Thanks in advance!

Upvotes: 1

Views: 776

Answers (1)

Abhijit Gohokar
Abhijit Gohokar

Reputation: 1

Have you tried adding the test classes in @SpringBootTest? like so: @SpringBootTest(classes = YourTestClass.class)

Upvotes: 0

Related Questions