Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Prakash-QA opened this issue Jul 8, 2023 · 4 comments
Closed

Comments

@Prakash-QA
Copy link

Prakash-QA commented Jul 8, 2023

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.

@shivam-sehgal
Copy link

@Prakash-QA, tags expect a logical operator between them. For example, if you pass "@Set1 or @SET2", it will work as expected. The "beforeall" will be executed first, and "before" will be executed before each scenario. However, I noticed that if we use a comma (",") between two tags like you did, it doesn't give the expected error. Let's proceed with running it, and I will look into it further.

@Prakash-QA
Copy link
Author

@Prakash-QA, tags expect a logical operator between them. For example, if you pass "@Set1 or @SET2", it will work as expected. The "beforeall" will be executed first, and "before" will be executed before each scenario. However, I noticed that if we use a comma (",") between two tags like you did, it doesn't give the expected error. Let's proceed with running it, and I will look into it further.

Thank you @shivam-sehgal . When I use conditional operator it works.

@shivam-sehgal
Copy link

Hello, @mpkorstanje has submitted a pull request PR to address this issue. This PR aims to prevent others from encountering the same problem. I kindly request a review of the changes to ensure their effectiveness and potential integration into the project. Your assistance and feedback would be greatly appreciated.

@Prakash-QA
Copy link
Author

Hello, @mpkorstanje has submitted a pull request PR to address this issue. This PR aims to prevent others from encountering the same problem. I kindly request a review of the changes to ensure their effectiveness and potential integration into the project. Your assistance and feedback would be greatly appreciated.

Thank you for the update

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants