-
Notifications
You must be signed in to change notification settings - Fork 753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Rule Backgrounds. #2668
Add support for Rule Backgrounds. #2668
Conversation
Open to suggestions for improvements. |
…and code. Lacks tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is generally fine, thx! Please check my smaller notes below.
TechTalk.SpecFlow.Generator/Generation/UnitTestMethodGenerator.cs
Outdated
Show resolved
Hide resolved
Tests/TechTalk.SpecFlow.Specs/Features/Parser/RuleSupport.feature
Outdated
Show resolved
Hide resolved
…ethodBody to accept a ScenarioDefinitionInFeatureFile instead of an AST Scenario. This allows simpler tracking of the relationship between Scenario and Rule. Refactored Rule Background support in ScenarioPartHelper to simplify the code and accept changes suggested during PR review.
…h multiple Rules, each having a Background; the Background steps should only be executed for the Scenario(s) within their respective Rule.
@gasparnagy Thank you so much for the review comments and suggestions! I've incorporated your suggestions, resulting in a greatly simplified implementation (largely isolated to the SPH). I am having a problem with adding a Feature file to the SpecFlow.Specs tests however. Pls see my latest commit to this PR (#565afff). When executed the test fails with a TechTalk.SpecFlow.BindingException "Ambiguous step definitions..." Any suggestions? |
@gasparnagy never mind on the problem with ambiguous step definitions; I figured it out. My problem :). This PR ready for final review/approval. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove that one scenario and then we are ready to go, i think.
Tests/TechTalk.SpecFlow.Specs/Features/Parser/RuleSupport.feature
Outdated
Show resolved
Hide resolved
public class RuleSteps1 | ||
{ | ||
|
||
[Given("something first as background")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this formatting only broken on GitHub or also in VS?
If so, please fix it. Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is really hard to read for me in this style
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SabotageAndi I have rewritten this feature file in an attempt to improve its readability. Please let me know what you think.
RuleBackgroundExecution.feature
…ub.com/clrudolphi/SpecFlow into SF2664_Add_Support_for_Rule_Background
Removed. This feature file now reverted to what is in Master. |
@gasparnagy @SabotageAndi - checking in with you on this. I believe all prior suggestions/concerns are addressed. Are there any other changes you would like to see? |
@clrudolphi Thx! It took a bit more time... sry |
@SabotageAndi great news! awesome feature! Congrats. |
Has this already been released? Can't see it working in latest SpecFlow for Visual Studio 2022 released Dec 20 2022 |
It was incorporated into the v4.0.31-beta build (built on 15 Dec 22). |
* Add support for Rule Backgrounds. Preliminary commit. Lacks tests. * Add support for Rule Backgrounds.Revised Commit to simplify approach and code. Lacks tests. * Refactored signature of method: UnitTestMethodGenerator.GenerateTestMethodBody to accept a ScenarioDefinitionInFeatureFile instead of an AST Scenario. This allows simpler tracking of the relationship between Scenario and Rule. Refactored Rule Background support in ScenarioPartHelper to simplify the code and accept changes suggested during PR review. * Adding a feature file in the Specs tests to demonstrate a Feature with multiple Rules, each having a Background; the Background steps should only be executed for the Scenario(s) within their respective Rule. * Further simplification of Rule support in SPH by merging two private methods together. * Corrected feature's binding code. Tests now pass. * Updating changelog * Reverting this feature back to the version present in SpecFlowOSS/SpecFlow. * Refactored/revised to improve readabliity and formatting Co-authored-by: Gáspár Nagy <[email protected]>
This PR adds support for Rule Backgrounds.
Most of the additional logic has been added to the ScenarioPartHelper class:
Types of changes
Checklist: