Cucumber `--tags` options from command line?

28,356

Lets pretend this is your feature:

Feature ABC

@executeThese
Scenario: abc1

@WIP @executeThese
Scenario: abc2

What you are currently doing is equivalent to an AND operation. so only abc2 will be run

In order to run both you need to do an OR operation equivalent to do this run:

cucumber -t @WIP,@executeThese This will run abc1 and abc2

If you want to execute all that are @executeThese But Not @WIP you need to do this:

cucumber -t @executeThese -t ~@WIP

This will run abc1 only

Share:
28,356
Ranjith's
Author by

Ranjith's

ISTQB tester with over 8 years of experience in performing QA activities for web and client-server applications.

Updated on June 16, 2020

Comments

  • Ranjith's
    Ranjith's almost 4 years

    What i would like to do is to pass cucumber options from command line to execute scenarios with tag name @extecuteThese but also i wanted to exclude scenarios that are with tag name @WIP so what am i doing so far is

    -Dcucumber.options='--tags @executeThese --tags ~@WIP' 
    

    But unfortunately, it's not considering ~@WIP tag option

    Any help, much appreciated!!

  • Ranjith's
    Ranjith's almost 8 years
    Thanks @Mo H. The scenario which failing is for me is cucumber -t @execute1,execute2 -t ~@WIP
  • diabolist
    diabolist almost 8 years
    You need to be consistent about how you reference the tags in your command line. In your comment you do this in 3 different ways (@tag, tag and ~@tag). Everything you need is in the help if you read it carefully (cucumber --help, look at the -t section)
  • Tihamer
    Tihamer over 3 years
    You can call Cucumber from the command line? Unfair! I can't. However, I can call Cucumber through Maven: mvn test -Dcucumber.options="–-tags @MyTaggedScenarioName" BTW, thanks a million for the -t hint. I was able to look at the man page by doing: mvn test -Dcucumber.options="–help"
  • Mo H.
    Mo H. over 3 years
    @Tihamer Yes you can actually with java aswell! Although not how I've shown it, i've used cucumber with ruby and it gives you a nice CLI. If you wanna do it with java: stackoverflow.com/questions/30586937/…. I'm glad that this answer is still helping people :)
  • Tihamer
    Tihamer about 3 years
    Thanks, but it turned out that going through maven was way too slow. But your hint gave me the idea of calling cucumber directly from Java: as in cucumber.api.cli.Main. Turned out a bit tricky, but it was easier than overwriting the CucumberOption annotations.
  • Mo H.
    Mo H. about 3 years
    @Tihamer can you elaborate? What part was slow?