June 2017
Intermediate to advanced
256 pages
5h 38m
English
Cucumber has a very interesting feature of hooks that helps us execute a block of code before or/and after each scenario. It can be defined anywhere in the step definitions using the Before and After methods. Most of the xUnit tools support a concept of the setup and tear down method, which is represented by Before and After here.
By default, these hooks are global in nature, and they run for every scenario. Here, an interesting concept to understand is that the step definitions are global in nature; there is no way to reduce the scope of step definitions to certain scenarios.
A sample of the Before hook is as shown:
@Beforepublic void setUp() throws IOException { System.out.println("This is a set up method and will be ...
Read now
Unlock full access