Search code examples
javaspring-bootcucumber

Prevent running an spring boot task which implements CommandLineRunner


I am writing a spring boot integration test using cucumber for a task (non web application) which implements CommandLineRunner. Due to default behavior of commandLineRunner, even after running the cucumber feature as junit, it runs the task first and then come backs to cucumber feature file. Instead I expect it not to run the task and control should come to feature file once the configuration is done.

How can I prevent CommandLineRunner from running its run method?


Solution

  • Add @Profile(“!profile_name”) annotation to the bean declaration and then set that profile when you need to exclude it