1
votes

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!

1
Please take a look at here - Ebrahim Pasbani
yes Autowire the requied one and mock the unwanted one - Deadpool

1 Answers

0
votes

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