Styrow.dev
Question 26 of 27
Cucumber Topic: General medium

Explain Cucumber Hooks

Question

Explain Cucumber Hooks

Answer

Cucumber Hooks are blocks of code that can be used to run before and after the scenarios using @before and @after methods. It helps us eliminates the redundant code steps that we write for every scenario and also manages our code workflow.

2 3 4 5 6 7 8 9 10 11

public class Hooks {

@Before
public void before(){
    System.out.println(""This will execute before every Scenario"");
}
@After
public void after(){
    System.out.println(""This will execute after every Scenario"");
}

}