I was trying to Ignore my scenarios for my Calabash Feature file (Ruby) using #ignore. But i can still run ignored scenarios. I have latest calabash version with Ruby 2.0. please suggest me other ways to ignore scenarios in calabash Ruby feature file
The easiest way is to use tags.
For example if you have 5 scenario and you want to run only 3 of it, then assign a tag to the those three scenarios which you want to run and run the script with tags.
example:
scenario 1
#run
steps
scenario 2
steps
scenario 3
steps
scenario 4
#run
steps
scenario 5
#run
steps
command: calabash-android run application.apk --tags #run
this will run your scenario 1,4 and 5
Cucumber doesn't automatically ignore tests that are labeled with #ignore, it is the same as any other tag.
When you run the tests add this (note the tilda ~)
--tags ~#ignore
and cucumber will ignore those tests.
i.e.
rake cucumber --tags ~#ignore
You can also use tags the same way to control tests you want to only run on certain environments etc.
Related
I'm running protractor flake on Jenkins for automation testing using the framework protractor cucumber. Each time the tests run, a json is outputted. Is there a way to delete the old json output or a bash command that can detect if protractor flake is rerun. I have protractor flake set to have 3 attempts. So if protractor flake reruns the 3rd time, I don't want the 1st and 2nd json output from protractor cucumber to be in the folder.
That way the cucumber report won't have flake tests in it.
This is the command I have right now on Jenkins when I do a build:
rm -rf e2e/reports
mkdir e2e/reports
npm install
node flake e2e/staging.protractor.conf.js
There is an onCleanup field/function in the protractor config. I recommend using that to write yourself a function that will delete the files in /e2e/reports. You can use the exitcode to delete the file if the first or second attempt fails. This will be a little tricky as you will need to find a way to keep track of which iteration you are on so that the report doesn't get deleted if the third run fails also.
See the comments in the protractor config for more details.
i have feature file ALLTests having couple of scenarios
Ex: TC1 , TC2 ,TC3 , TC4
I want to run only TC2 and TC4 from ALLTests through maven command , how to achive this ?
I tried "--tags #ALLTests,#TC1,#TC2" it ran all testcases from ALLTests feature file .
EDITED
See Tag Expressions
--tags '#ALLTests and not (TC2 and TC4)'
As far as Maven, take a look at cucumber tags based on maven profile
From the docs:
"
Tags are a great way to organise your features and scenarios.
They can be used for two purposes:
Running a subset of scenarios
Scoping hooks to a subset of scenarios
"
"You can tell Cucumber to only run scenarios with a particular tag" (Source: Running a subset of scenarios)
And you can use tag expressions to specify subsets of features/scenarios.
Multiple tags in the cucumber doesnt run the scenarios.
I have two different tags, tagged to two different scenarios under the same feature file. I try to run both the scenarios that are tagged, using the cucumber tags command
cucumber --tags #billing --tags #important
When I run this, cucumber doesn't recognize the scenarios, it provides the output like
0 scenarios
0 steps
0m0.000s
But when I run the tags individually, like cucumber --t #billing the cucumber is able to recognize and runs the scenario. Any idea why?
Any help is appreciated.
Simply if you define like above ( cucumber --tags #billing --tags #important ) , there should be a scenario having both #billing and #important tags.
if you are looking for cucumber to pick up when matching any of the tags,
use as below.
cucumber --tags #billing , #important
I've been working with Cucumber and Watir for the past few months locally to run some regression tests on our application. I have several Cucumber feature files in one repository with one step file and one environment file. Recently I have moved from running this locally to running it on Jenkins along with the cucumber-jvm reports plugin.
I set the build steps up with the following:
cucumber --format json all/features/publish.feature > result_publish.json
cucumber --format json all/features/signin.feature > result_signin.json
cucumber --format json all/features/reports.feature > result_reports.json
When there are no failures with the tests all feature files run successfully one after the other. However, if there is a failure with the first test the build will fail and the subsequent tests will not run.
Is there any way I can force all feature files to run even if one of them fails?
Put the features in the same folder and run
cucumber --format json all/features/integration -o results.json
This will create one single report with all the tests and will run all the features regarding if they fail or not
Given someone has added the following to their RunTests.java:
#Cucumber.Options(
format = {"pretty", "html:target/cucumber", "json:target/cucumber.json"},
tags = "#myTag",
features = "src/test/resources/features" )
Is there a way to make sure all scenarios are executed when running maven via a command line, e.g. on a continuous integration platform, like the following:
mvn clean test -Dcucumber.options="src/test/resources/features --tags #myTest"
Put differently, is there a command line option to force cucumber to "execute all features", e.g. using something like
mvn clean test -Dcucumber.options="src/test/resources/features --tags "
And am I correct in assuming
--tags ~#doNotRunMe
will execute all tags except the one mentioned?
If so, would
--tags ~#nonexistantTag
achieve what I'm after?
The answer is Yes, as pointed out by Björn in the Cukes Google Group.
He also pointed out that Cucumber-jvm supports AND and OR-like "links" for tags, and pointed me to the Cucumber Hooks wiki page, about which I had forgotten.