Search code examples
cucumbercucumber-java

Cucumber not recognizing tags


I have a strange issue with Cucumber not recognizing tags. I want to exclude one scenario from executing but it is still being executed. I am using cucumber 6.10.2 version (io.cucumber).

So the scenario is:

@tag1
  Scenario Outline: Attempt to Create Contract                
    Given I delete all test data for <some collection name>
    And I delete all test data for <other collection name>

My runner class is:

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

        @RunWith(Cucumber.class)
        @CucumberOptions(
                features = "src/test/java/resources"
                , glue = {"stepDefinitions"}
                , plugin = {"pretty", "html:target/cucumber-reports",
                "html:target/cucumber-report/cucumber.html",
                "html:target/cucumber-report.html",
                "json:target/cucumber.json"}
                , tags = "not @tag1"
    
    )
    
    public class RuneCukeTest {
    }

I also tried different syntax for tags such as:

tags = ~"@tag1"
tags = "~@tag1"

but none is working. (even if I try to run only this tag). it is not allowing me to type it this way probably because of the version:

tags = {"@tag1"}

What I found under "tags" documentation is:

  String tags() default "";

and example above it "@smoke and not @fast"

NOTES:

I am using few .feature files and I want to execute only one and skip only 1 scenario from it. I am trying both - to execute it from the runner class with the @CucumberOptions and by right clicking on the .feature file itself. Nothing is working...


Solution

  • This one works for me tags = "@Integration or @Wip and not @SmokeTest and not @Ignore"