3

I am trying to run just one feature file in protractor. I know that I can declare that file in protractor.conf.js, but I have also seen a solution by use of a tag:

In a feature file one would insert a tag at the beginning of the file like so:

@onlyRunThis

and protractor would only execute that file. (One could call it an E2E-equivalent of "fdescribe")

How would I implement such a tag? Can I even implement my own tags in protractor/cucumber? As you see I am quite sketchy on the whole matter.

I did find another question here on SO, which addresses the same issue (How to run only one feature file when running protractor with cucumber?) but none of the solutions work for me.

Thanks! :-)

Tobias Gassmann
  • 11,399
  • 15
  • 58
  • 92

2 Answers2

3

The above solution did not work for me. The following should work

protractor conf.js --cucumberOpts.tags="@onlyRunThis"

This will run all scenarios which have the tag @onlyRunThis set. When you add a tag to a feature then all scenarios inside it are run.

If you don't want to use tags for this you can call the command

protractor conf.js --specs=path/to/feature

Both work for me.

sininen
  • 503
  • 1
  • 6
  • 20
0

Use can use tags in protractor-cucumber but it will be at feature level. And when you pass tag as an argument all the feature files (which match the specs configuration) will be scanned for those tags. It goes as follows:

  1. If I have a 2 feature files with 3 scenarios each but only one scenario from each feature file has a tag @onlyRunThis, then passing the tag @onlyRunThis during the command line will run only these 2 scenarios one from each feature file.
  2. If I have 2 feature files with 3 scenarios each but only 2nd feature has one scenario with a tag @onlyRunThis, then passing the tag @onlyRunThis during command line would try to execute both the feature files and the result would be as follows: 0 scenarios from feature-file-1 & 1 scenario from feature-file-2

In case if you would like to execute only the tag in a specific feature file you can do it as follows:

protractor conf.js --specs=feature-file-1.feature --tags=@onlyRunThis
Rakesh
  • 329
  • 5
  • 16