Reputation: 2673
I have one scenario that has many steps, and its whole purpose is data generation, for example:
Scenario: Data generation
Given dataGen statement 1
And dataGen statement 2
...
And dataGen statement 100
I want to use this entire scenario (i.e. all 100 statements) as a single step in another scenario. I want to do something like:
scenario: Data generation and then assert
(everything in previous scenario)
Then I assert my assertion
But it would be silly to copy and paste everything.
Is there a way in Cucumber to make a call to a scenario as a single step? or to group the 100 statement into some structure as a whole and call it?
Upvotes: 2
Views: 1211
Reputation: 9058
Not sure if there is a way to call a scenario step from another in cucumber-jvm. Some kind of nesting steps is allowed in ruby implementation. You can try the belowin java.
Convert your scenario into scenario outline with two tables with their own tags. When you want to only generate data pass @Data
tag to cucumberoptions
of your runner class. And @DataAndAssert
when both operations are required. Base the logic in the assertion step with the value of the boolean flag.
Scenario Outline: Data generation and then assert
Given dataGen statement 1
And dataGen statement 2
...
And dataGen statement 100
Then I assert my assertion <flag>
@Data
Examples: Data Generation Only
| flag |
| false |
@DataAndAssert
Examples: Data Generation And Assertion
| flag |
| true |
Upvotes: 1