Closed shihai1991 closed 1 year ago
This looks similar to steps in steps in ruby, which is something we're advising heavily against.
Ideally if you have lots of common steps, you should use that languages abstraction techniques. So in ruby this would be a module or a class, and similar in Java.
Then you would call the methods in the steps. so something like.
Given('I log in as user {word} with password {word}') do |user, password|
# method here to login, using a class or module
end
This Stack Overflow thread: https://stackoverflow.com/a/23092261
Refers to this discussion: https://groups.google.com/g/cukes/c/DzE_kGZx94I/m/5rf__N31qvAJ
which can be summarized as "Gherkin is a collaboration tool, not a programming language". What makes your request different?
Ideally if you have lots of common steps, you should use that languages abstraction techniques. So in ruby this would be a module or a class, and similar in Java.
Thanks for your suggestion. You are right. Using some computer languages' techniques can resolve this problem too. But I would prefer to use StepMacros
to combine those steps. Some of my reasons:
# create VPC1
# Of Course, we can combine the multi step description in one step
# something like: When create a VPC with the the Availability region with the Availiability zone with ipv4...
# But the test scenario should be flexible and combinable. But the combined step lost the flexibility.
When build a VPC_Request_Body
And choose the Availability region in VPC_Request_Body
And choose the Availiability zone in VPC_Request_Body
And set the ipv4 in VPC_Request_Body
And set the subnet in VPC_Request_Body
And create an VPC with VPC_Request_Body
Then VPC created successful
# create VPC2
# the creation operation will be repeated in here, but the property ov VPC2 will be different
# create ECS1 in VPC1
# create ECS2 in VPC2
# test the connectivity between ECS1 and ECS2
Refers to this discussion: https://groups.google.com/g/cukes/c/DzE_kGZx94I/m/5rf__N31qvAJ which can be summarized as "Gherkin is a collaboration tool, not a programming language". What makes your request different?
Oh, thanks for your information. Looks like my request is not different with the discussion.
Some points from cucumber-waves-goodbye-to-givenscenario
Difficult to understand isolated scenarios
I think we can't consider this problem If the IDE support to find and link the related scenario. The IDE is much better now than 10 years ago.
Creating setups which pretend to be scenarios
If the user need use this feature. IMHO, the key word GivenScenario
could be updated to CombinedGiven
、CombinedWhen
and so on.
Noise in the output
We don't focus on the output until we meet the failed testcase.
I'm going to close this. We've briefly spoken about it in the committers meeting and async, and given this is something we are strongly advising against - all languages have their own paradigms. We advise using those.
🤔 What's the problem you're trying to solve?
I have many colleagues to develop step functions. After some times, we have many similar steps or groups of step. IMH, Using MacroSteps can help us manage the common steps.
✨ What's your proposed solution?
Some BDD framework support StepMacros.
In Chorus BDD, the example looks like:
In Behave, it looks like:
The issue discuss in pytest-bdd.
⛏ Have you considered any alternatives or workarounds?
📚 Any additional context?
This text was originally generated from a template, then edited by hand. You can modify the template here.