Reputation: 1477
Feature File
@ActivateSegment
Feature: Test for Activate segment
Scenario: Login
Given I navigate to M
And I enter user name
And I enter password
And I login to MM
Scenario: Open grid
Given I choose menu
And I choose Segments menu
Scenario: Open segment creation page
Given I click on New button
And I click on Segment button
Upvotes: 43
Views: 153250
Reputation: 29
You could use a Before hook and skip_this_scenario
like this:
Before('@test_that_needs_fancy_pants_flag') do
fancy_pants_toggle = DataUtils.get_toggle_setting('fancy_pants')
skip_this_scenario unless fancy_pants_toggle
end
Upvotes: 0
Reputation: 652
The JUnit 5 equivalent for this is now:
@ConfigurationParameter(key = FILTER_TAGS_PROPERTY_NAME, value = "not @Ignore")
Upvotes: 2
Reputation: 11
To skip the test from execution Use ' not' instead of '~'( option has been updated) Ex:
tags= "not @tag1"
Upvotes: 0
Reputation: 351
Simply use a different tag than you defined in CucumberOptions.
Let's say here you use "@regression" to runs tests:
@CucumberOptions(glue = { "stepDefinitions" }, tags = { "@regression" }, plugin = { "pretty",
"io.qameta.allure.cucumber4jvm.AllureCucumber4Jvm" }
In Feature file just use a different tag than "@regression":
Upvotes: 1
Reputation: 4773
From the command line, you can write
mvn test -DCucumber.options="--tags '@login and not @grid'"
put double quote ("") outside and single quote(') inside
Upvotes: 3
Reputation: 556
Using the JUnit runner class
and with reference to https://cucumber.io/docs/cucumber/api/#ignoring-a-subset-of-scenarios
You can create your own ignore tag
import cucumber.api.CucumberOptions;
import cucumber.api.junit.Cucumber;
import org.junit.runner.RunWith;
@RunWith(Cucumber.class)
@CucumberOptions(tags = "not @ignore")
public class RunCucumberTest {
}
Then just tag the scenario like so:
@ignore
Scenario: Check if all the 3 categories of cats are displayed
Given I open the Cats App
When I view the home screen
Then I should see all three cats categories displayed
Upvotes: 26
Reputation: 1744
According to Cucumber.io there are 2 styles in which a tag expression can be defined. For your specific case, to exclude steps or features marked with @ignore, these 2 styles translate into:
cucumber --tags ~@ignore
cucumber --tags "not @ignore"
.To my surprise, using the same cucumber-js v1.3.1 running on Node.js v6.9.2, I found that the Windows version accepted only the new style, while the Linux one accepted only the old style. Depending on your setup, you may want to try both and see if you succeed with any of them.
Upvotes: 41
Reputation: 491
@ActivateSegment
Feature: Test for Activate segment
Scenario: Login
Given I navigate to M
And I enter user name
And I enter password
And I login to MM
Scenario: Open grid
Given I choose menu
And I choose Segments menu
@avoid
Scenario: Open segment creation page
Given I click on New button
And I click on Segment button
in cucumber options
in runner class, use the tags as shown below that you don't want to run: tags = {"~@avoid"}
Upvotes: 4
Reputation: 1606
I believe the special tag @wip
already has native support, and can be used without any other code additions.
It even has a related command line switch:
-w, --wip Fail if there are any passing scenarios.
Upvotes: 3
Reputation: 1209
*.feature
@skip_scenario
Scenario: Hey i am a scenario
Given blah blah
And blah blah blah
CucumberHooks.java
package CucumberHooks;
import cucumber.api.Scenario;
import cucumber.api.java.Before;
public class CucumberHooks {
@Before("@skip_scenario")
public void skip_scenario(Scenario scenario){
System.out.println("SKIP SCENARIO: " + scenario.getName());
Assume.assumeTrue(false);
}
}
Upvotes: 23
Reputation: 7097
Use tag ~@tag_name
To exclude scenarios with a certain tag
cucumber --tags ~@tag_name
Note I used ~
symbol.
One thing to note here is that Cucumber will exit with a status of 1 if your @wip-tagged scenarios pass (it’s a reminder that they’re not works in progress anymore since they pass).
@billing
Feature: Verify billing
@important
Scenario: Missing product description
Scenario: Several products
cucumber --tags @billing # Runs both scenarios
cucumber --tags @important # Runs the first scenario
cucumber --tags ~@important # Runs the second scenario (Scenarios without @important)
Offical document: https://github.com/cucumber/cucumber/wiki/Tags
Upvotes: 36