cucumber - SpecFlow -- Step (Given) with the same regex in different classes not executing independently -
I have two classes (class A and B) both marked with [binding]. Currently I am using one class per attribute, I is a step in both class A and B which looks like this:
[given (An employee (. *) ( . *) Is (*. *) On a (. *) ")] When I run the scenario for the features defined in class A, and the test runner indicates the step is executed, Is implemented instead. What are the "steps" in the global form? Had thought that only "hook" methods are global, such as Ascenario, before Badassenario, I do not want to do this behavior for "given", "then", and "when" is there any way to correct it? - tried to put two classes in different names and it does not work either.
Besides, do I have to get each "given" to be independent by putting them into different classes Probably the talk of SPE I'm using it?
Yes the steps (per default) are global, then you will get in trouble if you Define two attributes in which there are RegExps that match the same stage even if they are in different classes
with some classes being in different classes, or other placements (also in other assembly) Not even how the Spencho Group does it - this is just a big list of the given list When and later it tries to match the move
But there is a facility called the Scodd Steps that solves this problem for you: see it here:
This idea is That you put another attribute (steppescope) on your step definition method and then respect that scoping. For example:
[given (@ ("I have a step definition which is scotched to tag (?:. *)")] [StepScope (Tag = "Mytag")] Public Zero gave IHaveAStepDefinitionThatIsScopedWithMyTag () {stepTracker.StepExecuted ("I have given a step definition which is scotched to tag the 'tag');} ... or a full range definition class in a feature range:
[binding] [step scope (feature = "turning light should make it bright") ] Public square TurningOnTheLightSteps {// ...} This step is using a StepScope definition tag for you
- Tag
- Scenario title
- Feature title
Great question: I did not fully understand what was so far;)
Comments
Post a Comment