11

I know you can specify tags for features and then ignore them when running cucumber on the command line. But I'm using cucumber-jvm and running it from maven. @ignore doesn't work and I wouldn't know how to pass the to-be-ignored tags to the runner that executes the Gherkin tests.

The work-around is to move feature that are done to another directory while developing and testing new ones, but that's not how it should be. How do other users deal with this deficiency?

2 Answers 2

23

You can tell runner skip @ignore

import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@Cucumber.Options(features = {"classpath:my_feature.feature"},
tags = {"~@ignore"})
public class RunCukesTest {
}
5
  • Works like a charm! I prefernt @Ignore to be consistent with JUnit. Jun 7, 2014 at 5:00
  • 2
    This is actually the correct answer. The ~ operator is used to designate tags to be skipped. The accepted answer works but is a roundabout way to achieve it, because typically the number of scenarios to ignore is less. There should be no need to tag all the scenarios you want to run (unless this helps in other ways).
    – BakaTono
    Feb 4, 2015 at 18:58
  • I noticed that without this explicit tag filter (exclude @ignore) ; @ignore is not undertaken by default; so I just updated the wiki page wich tell about "@ignore" tag : github.com/cucumber/cucumber/wiki/Tags
    – boly38
    Dec 15, 2015 at 15:18
  • 2
    The name of the tag is not relevant, any tagname that is specified in the runner with tags = {"~@tagname"} will be ignored. The @ignore tag is therefore not a special tag.
    – iamallama
    Feb 26, 2016 at 9:21
  • I have tried with your solution. But, it doesn't skip the scenarios at all. I have given like this in my runner class" tags = {"@GeoY/NModal1ItemOfEachTypeSaveToCampaign", "~@ignore"}," and then I use @ignore in feature file for particular scenario. Can you tell me the , What I am missing here?
    – selvi
    Apr 29, 2016 at 5:09
7

You can tag your scenarios as @ignore which will be ignored.

If you want to run only selective scenarios then mark your every new feature that you want to test as @new_test. Tell the Cukes Runner to run only tags = @new_test

import org.junit.runner.RunWith;
import cucumber.api.junit.Cucumber;

@RunWith(Cucumber.class)
@Cucumber.Options(features = {"classpath:my_feature.feature"},
tags = {"@new_test"})
public class RunCukesTest {

}

Anything that you don't want to test should not have a tag or should have some other tag name

2
  • thanks for the "tags" option, that seems to work; I believe if the test is in the same package as the features you can leave out the "features" option, which is quite handy; if you needed to list each feature here, you could also do without the tag, after all... Oct 3, 2013 at 9:22
  • This has helped me specifically when I am creating new features and scenarios. I'll only want to run the new ones at the beginning and this answer does the trick.
    – Jeremy
    Nov 5, 2015 at 13:38

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.