Skip to content

Commit e5b4e3d

Browse files
authored
Revert "Complete the doc to highlight that no parameter hooks work fine"
1 parent 2bae24d commit e5b4e3d

File tree

2 files changed

+13
-19
lines changed

2 files changed

+13
-19
lines changed

docs/hooks.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Scenario hooks run for every scenario.
1414
`Before` hooks run before the first step of each scenario.
1515

1616
```scala
17-
Before {
17+
Before { scenario : Scenario =>
1818
// Do something before each scenario
1919
}
2020
```
@@ -24,7 +24,7 @@ Before {
2424
`After` hooks run after the last step of each scenario.
2525

2626
```scala
27-
After {
27+
After { scenario : Scenario =>
2828
// Do something after each scenario
2929
}
3030
```
@@ -36,36 +36,25 @@ Step hooks invoked before and after a step.
3636
### BeforeStep
3737

3838
```scala
39-
BeforeStep {
39+
BeforeStep { scenario : Scenario =>
4040
// Do something before step
4141
}
4242
```
4343

4444
### AfterStep
4545

4646
```scala
47-
AfterStep {
47+
AfterStep { scenario : Scenario =>
4848
// Do something after step
4949
}
5050
```
5151

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-
6352
## Conditional hooks
6453

6554
Hooks can be conditionally selected for execution based on the tags of the scenario.
6655

6756
```scala
68-
Before("@browser and not @headless") {
57+
Before("@browser and not @headless") { _ =>
6958
// Do something before each scenario with tag @browser but not @headless
7059
}
7160
```
@@ -75,11 +64,11 @@ Before("@browser and not @headless") {
7564
You can define an order between multiple hooks.
7665

7766
```scala
78-
Before(10) {
67+
Before(10) { _ =>
7968
// Do something before each scenario
8069
}
8170

82-
Before(20) {
71+
Before(20) { _ =>
8372
// Do something before each scenario
8473
}
8574
```
@@ -90,7 +79,7 @@ The **default order is 1000**.
9079

9180
You mix up conditional and order hooks with following syntax:
9281
```scala
93-
Before("@browser and not @headless", 10) {
82+
Before("@browser and not @headless", 10) { _ =>
9483
// Do something before each scenario
9584
}
9685
```

scala/sources/src/main/scala/io/cucumber/scala/ScalaDsl.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ package io.cucumber.scala
22

33
import java.lang.reflect.{ParameterizedType, Type}
44

5+
import io.cucumber.core.backend.{HookDefinition, StepDefinition}
56
import io.cucumber.scala.Aliases.HookBody
67

8+
import scala.collection.mutable.ArrayBuffer
9+
710
/**
811
* Base trait for a scala step definition implementation.
912
*/
@@ -18,6 +21,8 @@ trait ScalaDsl {
1821

1922
val registry = new ScalaDslRegistry()
2023

24+
// TODO support Before/After with no parameter
25+
2126
def Before(body: HookBody): Unit = {
2227
Before(EMPTY_TAG_EXPRESSION, DEFAULT_BEFORE_ORDER)(body)
2328
}

0 commit comments

Comments
 (0)