W
W
Wan-Derer2021-12-04 00:44:03
Java
Wan-Derer, 2021-12-04 00:44:03

Spring, how to make sure that the service does not start on tests?

I have a Spring Boot application.
It has a Service, to which one of the methods is marked as Scheduled, i.e. runs periodically.
There is also a standard folder with tests, in which I write tests of individual classes / methods of the application (unit tests) without launching the application itself (but with the launch of the "infrastructure" - databases, etc.)
So, when I run my tests, it starts up and Scheduled method, which I don't need at all!

How can I do this so that when the tests are run, this part of the "infrastructure" does not start?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Roo, 2021-12-04
@Wan-Derer

The answer is actually easy to google.
https://stackoverflow.com/questions/40684903/disab...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question