Skip to content

Commit 47e93d4

Browse files
committed
Add readme to cucumber-junit
1 parent 3ea236b commit 47e93d4

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

junit/README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Cucumber JUnit
2+
==============
3+
4+
Use JUnit to execute cucumber scenarios.
5+
6+
Add the `cucumber-junit` dependency to your pom.
7+
8+
```xml
9+
<dependencies>
10+
...
11+
<dependency>
12+
<groupId>io.cucumber</groupId>
13+
<artifactId>cucumber-junit</artifactId>
14+
<version>${cucumber.version}</version>
15+
<scope>test</scope>
16+
</dependency>
17+
...
18+
</dependencies>
19+
```
20+
21+
Create an empty class that uses the Cucumber JUnit runner.
22+
23+
```java
24+
package com.example;
25+
26+
import cucumber.api.CucumberOptions;
27+
import cucumber.api.junit.Cucumber;
28+
import org.junit.runner.RunWith;
29+
30+
@RunWith(Cucumber.class)
31+
@CucumberOptions(plugin = "json:target/cucumber-report.json")
32+
public class RunCukesTest {
33+
}
34+
```
35+
36+
This will execute all scenarios in the package of the runner. By default glue code is assumed to be in the same
37+
package. The `@CucumberOptions` can be used to provide additional configuration to the runner.
38+
39+
## Using JUnit Rules ##
40+
41+
Cucumber supports JUnits `@ClassRule`, `@BeforeClass` and `@AfterClass` annotations. These will be invoked around the
42+
suite of features. Using these is not recommended as it limits the portability between different runners. Instead it is
43+
recommended to use Cucumbers `Before` and `After` hooks to setup scaffolding.
44+
45+
## Using other JUnit features ##
46+
47+
The Cucumber runner acts like a suite of a JUnit tests. As such other JUnit features such as Categories, Custom JUnit
48+
Listeners and Reporters can all be expected to work.
49+
50+
For more information on JUnit, see the {{{http://www.junit.org}JUnit web site}}.

junit/src/main/java/cucumber/api/junit/Cucumber.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
* Additional hints can be given to Cucumber by annotating the class with {@link CucumberOptions}.
4949
* <p>
5050
* Cucumber also supports JUnits {@link ClassRule}, {@link BeforeClass} and {@link AfterClass} annotations.
51-
* These will be invoked around the suite of features" and moved to the end of the java doc.
51+
* These will be invoked around the suite of features. Using these is not recommended as it limits the portability
52+
* between different runners. Instead it is recommended to use Cucumbers `Before` and `After` hooks to setup scaffolding.
5253
*
5354
* @see CucumberOptions
5455
*/

0 commit comments

Comments
 (0)