0% found this document useful (0 votes)
11 views11 pages

Runners

Uploaded by

Swati Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views11 pages

Runners

Uploaded by

Swati Jaiswal
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

If feature file and stepDefs files are in same package, cucumber implicitly run.

But in case of different package other than java root package, need to explicitly
define to cucumber both paths. For this purpose, we use Runner file providing
location of both files explicitly.

Runners:
CLI: io.cucummber.core.cli.Main
Maven exec
Scenario in parallel

JUnit: Runner class


Supports annotated methods
Features in parallel
Not support scenarios in parallel

TestNG: Runner class


Supports annotated methods
Scenarios in parallel

CLI:
https://cucumber.io/docs/cucumber/api/?lang=java#from-the-command-line
java -cp "path/to/each/jar:path/to/compiled/.class/files" io.cucumber.core.cli.Main
/path/to/your/feature/files --glue hellocucumber --glue anotherpackage
Test scope means, src/test/java.
Note that if both feature file and stepdef in same package, no need to put path
in while running from cmd.

Eg:
Initially I delete the target folder and run from command line:

Now run mvn clean test, target folder is created;


Now run same command:

Using Junit:

Junit5 is quite different than Jnuit, we are using junit 4.


Note that if we are using java/test, then scope should test. In case of main,
scope should complile.

Note that Test keyword must in runner class name otherwise we are not able
to run with maven.
Now run this class using junit:

Not running because no feature file found, need to give path for the same.
Not if we run code from cli without maven, the statements in beforeclass and
afterclass are not displayed:
Cucumber 7 introduced a annotation that is @BeforeAll, it is equivalent to junit @BeforeAll. In
cucumber terms this is called as Hook.
Currently hooks – beforeAll and afterAll are not working with junit.

You might also like