Reputation: 5561
Is there any alternate way to run the cucumber without Junit.
Is that any possible way to run cucumber as a Java application.. like if I create a main() method and control all step definitions over there?
Any help will be awesome
Upvotes: 1
Views: 3505
Reputation: 1712
Cucumber JVM can be invoked from command line. So the answer below applies to any Java codes that can be invoked from command line, not just for Cucumber JVM (which is just another Java component/library).
You can invoke any Java main method from your own main method (or any other methods) through static method invocation. We just need to simulate how the command line arguments being passed.
So if you are able invoke the Cucumber JVM from command line:
java -jar cucumber-jvm.jar cucumber.api.cli.Main --strict --glue com.mycompany.glue --plugin pretty
This is an example how you can do that from your own Java code:
public class MyMainClass {
public void main(String[] args) {
String[] args = new String[] {
"--strict",
"--glue",
"com.mycompany.glue",
"--plugin",
"pretty"
};
cucumber.api.cli.Main.main(args);
}
}
Upvotes: 2
Reputation: 2819
The answer is out of date. The cucumber docs have this to say, "Running Cucumber
There are several ways to run scenarios with Cucumber-JVM:
Upvotes: 2
Reputation: 283
Cucumber is just another custom Junit runner. so can not have cucumber without Junit.
Upvotes: -2