@@ -14,7 +14,7 @@ Scenario hooks run for every scenario.
14
14
` Before ` hooks run before the first step of each scenario.
15
15
16
16
``` scala
17
- Before { scenario : Scenario =>
17
+ Before {
18
18
// Do something before each scenario
19
19
}
20
20
```
@@ -24,7 +24,7 @@ Before { scenario : Scenario =>
24
24
` After ` hooks run after the last step of each scenario.
25
25
26
26
``` scala
27
- After { scenario : Scenario =>
27
+ After {
28
28
// Do something after each scenario
29
29
}
30
30
```
@@ -36,25 +36,36 @@ Step hooks invoked before and after a step.
36
36
### BeforeStep
37
37
38
38
``` scala
39
- BeforeStep { scenario : Scenario =>
39
+ BeforeStep {
40
40
// Do something before step
41
41
}
42
42
```
43
43
44
44
### AfterStep
45
45
46
46
``` scala
47
- AfterStep { scenario : Scenario =>
47
+ AfterStep {
48
48
// Do something after step
49
49
}
50
50
```
51
51
52
+ ## Scenario parameter
53
+
54
+ The scenario is available as parameter in all hooks.
55
+
56
+ You can use it like this:
57
+ ``` scala
58
+ Before { scenario : Scenario =>
59
+ // Do something with the scenario
60
+ }
61
+ ```
62
+
52
63
## Conditional hooks
53
64
54
65
Hooks can be conditionally selected for execution based on the tags of the scenario.
55
66
56
67
``` scala
57
- Before (" @browser and not @headless" ) { _ =>
68
+ Before (" @browser and not @headless" ) {
58
69
// Do something before each scenario with tag @browser but not @headless
59
70
}
60
71
```
@@ -64,11 +75,11 @@ Before("@browser and not @headless") { _ =>
64
75
You can define an order between multiple hooks.
65
76
66
77
``` scala
67
- Before (10 ) { _ =>
78
+ Before (10 ) {
68
79
// Do something before each scenario
69
80
}
70
81
71
- Before (20 ) { _ =>
82
+ Before (20 ) {
72
83
// Do something before each scenario
73
84
}
74
85
```
@@ -79,7 +90,7 @@ The **default order is 1000**.
79
90
80
91
You mix up conditional and order hooks with following syntax:
81
92
``` scala
82
- Before (" @browser and not @headless" , 10 ) { _ =>
93
+ Before (" @browser and not @headless" , 10 ) {
83
94
// Do something before each scenario
84
95
}
85
96
```
0 commit comments