'How to Override a OnApplicationEvent method from Running on StartupEvent in Tests in Micronaut Application

I have a OnApplicationEvent which executes some fancy scheduled code whenever the server spins up. What I want to do is disable/Override this Call for all at least some of my Unit Tests. I am working in Micronaut Application.

How can I do that?



Solution 1:[1]

The answer from pks18 on the @Requires(notEnv = Environment.TEST) helped me.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 RENATO MACIEL