Skip to content

@Before is not invoked when multiple tags are passed in the runner file #2776

Closed
@Prakash-QA

Description

@Prakash-QA

I'm passing multiple tags in my runner file tags = "@set1,@set2"

My Runner file looks like this

package com.qa.testrunners;


import io.cucumber.junit.Cucumber;
import io.cucumber.testng.AbstractTestNGCucumberTests;
import io.cucumber.testng.CucumberOptions;
import org.junit.runner.RunWith;

@RunWith(Cucumber.class)
@CucumberOptions(
        features = {"src/test/java/features"},
        glue = {"stepdefinitions", "com.qa.hooks"},
        monochrome = true,
        tags = "@set1,@set2",
        dryRun = false,
        plugin = {"pretty", 
                  "json:reports/cucumber/json-report.json",
                  "html:reports/cucumber/html-report.html"}
)
public class TestRunner extends AbstractTestNGCucumberTests {
}

I have my Hooks class like this

public class AllHooks{
 @BeforeAll
  public static void globalSetup(){
    //Setup methods
  }

  @Before
  public static void scenarioSetup(Scenario scenario){
    //Scenario setup
  }

   @AfterAll
  public static void globalTearDown(){
    //Teardown implementation
  }
}

My cucumber version - 7.12.1

When I execute the runner, I get @BeforeAll methods executed and then control goes to @afterall method and @before method was not executed. When I pass only one tag in the runner file then it all work fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions