File tree 2 files changed +52
-1
lines changed
src/main/java/cucumber/api/junit
2 files changed +52
-1
lines changed Original file line number Diff line number Diff line change
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}}.
Original file line number Diff line number Diff line change 48
48
* Additional hints can be given to Cucumber by annotating the class with {@link CucumberOptions}.
49
49
* <p>
50
50
* 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.
52
53
*
53
54
* @see CucumberOptions
54
55
*/
You can’t perform that action at this time.
0 commit comments