Reputation: 698
I have a Cucumber .feature
file with scenario outline like below.
Scenario Outline: eating
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | eat | left |
| 12 | 5 | 7 |
| 20 | 5 | 15 |
Is there a way to run only specific row(s) from the examples table during a test run?
Right now, I need to split this into two scenario outlines and tag one of them as @ignore
to accomplish this.
Does cucumber provide a way to filter examples during execution, maybe based on a column in the example table?
Upvotes: 3
Views: 2053
Reputation: 698
I found a pretty neat way to do this in the Cucumber docs after I read them extra-carefully.
The answer is directly in this page
It is possible to tag specific examples in the way given below:
Scenario Outline: Steps will run conditionally if tagged
Given user is logged in
When user clicks <link>
Then user will be logged out
@mobile
Examples:
| link |
| logout link on mobile |
@desktop
Examples:
| link |
| logout link on desktop |
This serves my purpose.
Upvotes: 3
Reputation: 12029
Assuming you're using Cucumber with JUnit 5, you can use:
@SelectClasspathResource(value = "com/example/application.feature", line = 42)
This will run the example on line 42.
If you're using Cucumber with JUnit 4, you can use:
@CucumberOptions(features = "com/example/application.feature:42")
Though as you are also using Serenity, neither may work.
Upvotes: 1