Tagged Hooks

Tagged Hooks are much like the scenario hooks but the only difference is that they are executed before and after the specified tag.

So basically, they can also be run in the following two ways:

  • Before ('tagName')
  • After ('tagName')

This can be used when we need some kind of a feature level setup and teardown, assuming that all the scneario are tagged with the same feature name.

In our example scenario, consider the following code to understand the concept.

public class StartingSteps extends DriverFactory {

    @Given("^the user is on landing page$")
    public void setup() throws Throwable {

    public void beforeScenario(){
        System.out.println("this will run before the actual scenario");

    public void afterScenario(){
        System.out.println("this will run after scneario is finished, even if it failed");

    public void signupSetup(){
        System.out.println("This should run everytime before any of the @Signup-DataDriven tagged scenario is going to run");

    public void signupTeardown(){
        System.out.println("This should run everytime after any of the @Signup-DataDriven tagged scenario has run");


results matching ""

    No results matching ""