You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ All user visible changes to `cucumber` crate will be documented in this file. Th
22
22
- Made test callbacks first argument `&mut World` instead of `World`. ([#128])
23
23
- Made `#[step]` argument of step functions `Step` instead of `StepContext` again, while test callbacks still receive `StepContext` as a second parameter. ([#128])
24
24
- Deprecated `--nocapture` and `--debug` CLI options to be completely redesigned in `0.11` release. ([#137])
25
-
-[Hooks](https://cucumber.io/docs/cucumber/api/#hooks)were removed, but are planned to be re-implemented with some changes in `0.11` release. ([#128])
25
+
-[Hooks](https://cucumber.io/docs/cucumber/api/#hooks)now accept optional `&mut World` as their last parameter. ([#142])
26
26
27
27
### Added
28
28
@@ -32,6 +32,7 @@ All user visible changes to `cucumber` crate will be documented in this file. Th
Copy file name to clipboardExpand all lines: book/src/Features.md
+78Lines changed: 78 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,8 @@ Occasionally you’ll find yourself repeating the same `Given` steps in all the
41
41
42
42
Since it's repeated in every scenario, this is an indication that those steps are not essential to describe the scenarios, so they are _incidental details_. You can literally move such `Given` steps to background, by grouping them under a `Background` section.
43
43
44
+
`Background` allows you to add some context to the `Scenario`s following it. It can contain one or more steps, which are run before each scenario (but after any [`Before` hooks](#before-hook)).
45
+
44
46
```gherkin
45
47
Feature: Animal feature
46
48
@@ -304,5 +306,81 @@ In case most of your `.feature` files aren't written in English and you want to
304
306
305
307
306
308
309
+
## Scenario hooks
310
+
311
+
312
+
### `Before` hook
313
+
314
+
`Before` hook runs before the first step of each scenario, even before [`Background` ones](#background-keyword).
> Whatever happens in a `Before` hook is invisible to people reading `.feature`s. You should consider using a [`Background`](#background-keyword) as a more explicit alternative, especially if the setup should be readable by non-technical people. Only use a `Before` hook for low-level logic such as starting a browser or deleting data from a database.
347
+
348
+
349
+
### `After` hook
350
+
351
+
`After` hook runs after the last step of each `Scenario`, even when that step fails or is skipped.
0 commit comments