cucumber / cucumber-jvm

Cucumber for the JVM
https://cucumber.io
MIT License
2.69k stars 2.02k forks source link

'FILTER_TAGS_PROPERTY_NAME' doesnt work with and, or & not operator #2877

Closed gorakshasabnis closed 2 months ago

gorakshasabnis commented 2 months ago

👓 What did you see?

When scenarios are executed using @dashbard-page tag like below: @ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@dashbard-page") then it executed scenarios tagged as 'dashbard-page'

When scenarios are executed using @smoke-test tag like below: @ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@smoke-test") then it executed scenarios tagged as 'smoke-test'

But, when both tags are used together like below: @ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@smoke-test and @dashbard-page") Then it runs all scenarios by ignoring tags

✅ What did you expect to see?

Expected multiple tags to be honored with reserved keywords like and, or, not etc. like older version of cucumber with JUnit4 i.e. cucumber.filter.tags

📦 Which tool/library version are you using?

pom.xml

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-api</artifactId>
    <version>5.10.2</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-java</artifactId>
    <version>7.16.1</version>
</dependency>
<dependency>
    <groupId>io.cucumber</groupId>
    <artifactId>cucumber-junit-platform-engine</artifactId>
    <version>7.16.1</version>
    <scope>test</scope>
</dependency>

Runner:

@Suite
@IncludeEngines("cucumber")
@SelectPackages("com.example")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example")
@ConfigurationParameter(key = EXECUTION_MODE_FEATURE_PROPERTY_NAME, value = "SAME_THREAD")
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@dashbard-page")
public class RunCucumberTest {
}

🔬 How could we reproduce it?

Steps Step1: Create 2-3 feature files with 4-5 scenarios each Step2: Add 4-5 different named Tags like @smoke-test, @sanity-test, @dashboard-page, @login-page etc. Step3: Pass more than one tag as intersection in the test suite like below: @ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "@dashboard-page and @sanity-test") Step4: Execute tests using JUnit5 runner

Expected Output: Only Scenarios with intersection should be executed.

Actual Output: All scenarios are running by ignoring tags in the suite. However, when a single tag is mentioned, it is honored.

📚 Any additional context?

No response

mpkorstanje commented 2 months ago

It seems I can't reproduce your problem. Could you clone the https://github.com/cucumber/cucumber-java-skeleton/ and try to reproduce it in there?

Alternatively, as you are running through the JUnit Platform, you could consider using the JUnit (not Cucumber) tag expression with @IncludeTags("a & b").

gorakshasabnis commented 2 months ago

it worked thanks