Now I'm disabling periodic tasks by setting of initialDelay for each periodic task with value 10h in an application configuration which is used during unit tests.
Then the annotation for task method is like this:
@Scheduled(fixedDelay = '10s', initialDelay = '${some-domain.periodic-task.initial-delay}')
void periodicTask() {
// periodic task implementation
}
And in application.yaml configuration used in unit test is:
someDomain:
periodicTask:
initialDelay: 10h
The question is: Is there a better way how to disable periodic task execution in Micronaut during unit test?
Because I feel that my solution is not nice - it's workaround. But I did not find any global setting for that or any specific annotation which can be used in unit test to achieve that etc.
Thank you