February 2015
Intermediate to advanced
338 pages
8h 16m
English
Cucumber supports hooks, which are methods that run before or after each scenario. You can define them anywhere in your support or step definition layers, using the annotations @Before and @After.
To test them, add a file src/test/java/hooks/SomeTestHooks.java that looks like this:
| support_code/13/src/test/java/hooks/SomeTestHooks.java | |
| | package hooks; |
| | |
| | import cucumber.api.java.After; |
| | import cucumber.api.java.Before; |
| | import cucumber.api.Scenario; |
| | |
| | public class SomeTestHooks { |
| | @Before |
| | public void beforeCallingScenario() { |
| | System.out.println("*********** About to start the scenario."); |
| | } |
| | |
| | @After |
| | public void afterRunningScenario(Scenario scenario) { |
| | System.out.println("*********** Just ... |