-
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
Merged
gasparnagy
merged 11 commits into
SpecFlowOSS:master
from
clrudolphi:SF2664_Add_Support_for_Rule_Background
Dec 15, 2022
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2c66944
Add support for Rule Backgrounds. Preliminary commit. Lacks tests.
clrudolphi bb93147
Add support for Rule Backgrounds.Revised Commit to simplify approach …
clrudolphi a6d4664
Refactored signature of method: UnitTestMethodGenerator.GenerateTestM…
clrudolphi 565afff
Adding a feature file in the Specs tests to demonstrate a Feature wit…
clrudolphi 85f54d5
Further simplification of Rule support in SPH by merging two private …
clrudolphi c534872
Corrected feature's binding code. Tests now pass.
clrudolphi fbff15f
Updating changelog
clrudolphi 42fce5b
Merge branch 'master' into SF2664_Add_Support_for_Rule_Background
gasparnagy 4a84874
Reverting this feature back to the version present in SpecFlowOSS/Spe…
clrudolphi ab1a52e
Refactored/revised to improve readabliity and formatting
clrudolphi f92020e
Merge branch 'SF2664_Add_Support_for_Rule_Background' of https://gith…
clrudolphi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 126 additions & 0 deletions
126
Tests/TechTalk.SpecFlow.Specs/Features/Execution/RuleBackgroundExecution.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
@gherkin6 | ||
Feature: Rule Background Steps Execution | ||
|
||
Scenario: Should be able to execute scenarios in Rules that have backgrounds | ||
Given the following binding class | ||
""" | ||
using TechTalk.SpecFlow; | ||
|
||
[Binding] | ||
public class RuleSteps1 | ||
{ | ||
|
||
[Given("something first as background")] | ||
public void GivenSomethingFirst() { | ||
global::Log.LogStep(); | ||
} | ||
|
||
[When("I do something")] | ||
public void WhenSomethingDone() { | ||
global::Log.LogStep(); | ||
} | ||
} | ||
""" | ||
Given there is a feature file in the project as | ||
""" | ||
Feature: Simple Feature | ||
Rule: first rule | ||
Background: first rule background | ||
Given something first as background | ||
|
||
Scenario: Scenario for the first rule | ||
When I do something | ||
""" | ||
|
||
|
||
When I execute the tests | ||
Then the binding method 'GivenSomethingFirst' is executed | ||
|
||
|
||
Scenario: Should be able to execute backgrounds from multiple Rules | ||
Given the following binding class | ||
""" | ||
using TechTalk.SpecFlow; | ||
|
||
[Binding] | ||
public class RuleSteps2 | ||
{ | ||
private bool first_background_executed = false; | ||
private bool second_background_executed = false; | ||
|
||
[Given("a first thing as background")] | ||
public void GivenaFirst() { | ||
global::Log.LogStep(); | ||
first_background_executed = true; | ||
} | ||
|
||
[Then("the first of two background item was executed")] | ||
public void ThenFirstOfTwoWasExecuted() { | ||
global::Log.LogStep(); | ||
if (!first_background_executed) { | ||
throw new ApplicationException("First Background Step should have been executed"); | ||
} | ||
} | ||
|
||
[Then("the first background item was not executed")] | ||
public void ThenFirstWasNotExecuted() { | ||
global::Log.LogStep(); | ||
if (first_background_executed) { | ||
throw new ApplicationException("First Background Step should not have been executed"); | ||
} | ||
} | ||
|
||
[Given("something second as background")] | ||
public void GivenSomethingSecond() { | ||
global::Log.LogStep(); | ||
second_background_executed = true; | ||
} | ||
|
||
[Then("the second background item was executed")] | ||
public void ThenSecondWasExecuted() { | ||
global::Log.LogStep(); | ||
if (!second_background_executed) { | ||
throw new ApplicationException("Second Background Step should have been executed"); | ||
} | ||
} | ||
|
||
[Then("the second background item was not executed")] | ||
public void ThenSecondWasNotExecuted() { | ||
global::Log.LogStep(); | ||
if (second_background_executed) { | ||
throw new ApplicationException("Second Background Step should not have been executed"); | ||
} | ||
} | ||
|
||
[When("I do something")] | ||
public void WhenSomethingDone() { | ||
global::Log.LogStep(); | ||
} | ||
|
||
} | ||
""" | ||
Given there is a feature file in the project as | ||
""" | ||
Feature: Simple Feature | ||
Rule: first rule | ||
Background: first rule background | ||
Given a first thing as background | ||
|
||
Scenario: Scenario for the first rule | ||
When I do something | ||
Then the first of two background item was executed | ||
And the second background item was not executed | ||
|
||
Rule: second rule | ||
Background: bg for second rule | ||
Given something second as background | ||
|
||
Scenario:Scenario for the second rule | ||
When I do something | ||
Then the second background item was executed | ||
And the first background item was not executed | ||
|
||
""" | ||
|
||
When I execute the tests | ||
Then all tests should pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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