I would like to disable "Spring Scheduling" in Spring Boot Tests. Is there any simple way? I was trying to find something... but I have not been successful.
Thank you.
Application.java
@EnableAutoConfiguration
@EnableScheduling
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
ProductionService.java
@Component
public class ProductionService {
@Scheduled(fixedRate = 1)
public void printName() {
System.out.println("-----PRINT NAME-----");
}
}
TestClass.java
@RunWith(SpringRunner.class)
@SpringBootTest
public class TestClass {
}
If I run tests in the TestClass, I get a lot of rows with -----PRINT NAME-----. I know, that configuration for @SpringBootTest is taken from @SpringBootApplication (in default setting). But my question is.. How can I disable scheduling in spring boot tests. Of course I can use separate configuration, but I have supposed there is a better and easier way how to do it. Something lika @EnableScheduling(enable=false)
Thank you.