Search code examples
javamavencucumbercucumber-jvmcucumber-junit

Java - Cucumber Tag Exclusion Not Working


I have created a Cucumber runner class, and I am attempting to run a particular subset of tests by including one Cucumber tag and excluding another. I am using Maven as a project manager.

package cucumber_runner;
import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
@RunWith(Cucumber.class)
@CucumberOptions(features = "src/test/resources/features/", 
    glue = "stepdefinitions",
    tags = {"@test", "~@homepage"})
public class RunCukesTest {

}

The result of running mvn test in the project folder, however, is that none of the Cucumber tests are run at all. Once I remove the ~ character from the tags, like so: tags = {"@test", "@homepage"}), the tests execute as expected, only considering feature files that have both the @test and @homepage tags. How do I properly exclude the @homepage tag from my tests?


Solution

  • I have been told in the comments that the syntax I was using was deprecated, so I looked up the new syntax: https://cucumber.io/docs/cucumber/api/#tags

    Leaving this here for future reference.