-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bugfix/fix reqnroll.verify parallelization (#255)
* Allow Reqnroll.Verify to run in parallel - Allow Reqnroll.Verify to run in parallel by registering a per-scenario VerifySettings - Added documentation on how to use Reqnroll.Verify. * Verify the code works when tests are executed in parallel * revert some of the formatting changes done to available-plugins.md * - used CustomizeScenarioDependencies in VerifyRuntimePlugin - Removed example for using verify in a single-threaded context as we would like users to not use that approach.
- Loading branch information
Showing
17 changed files
with
220 additions
and
42 deletions.
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
38 changes: 26 additions & 12 deletions
38
...s/Reqnroll.Verify/Reqnroll.Verify.ReqnrollPlugin.IntegrationTest/Features/Feature.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 |
---|---|---|
@@ -1,14 +1,28 @@ | ||
@DoNotParallelize | ||
Feature: Verify Test | ||
|
||
Scenario: Check if Verify is working | ||
When I try Verify with Reqnroll | ||
Then it works | ||
|
||
Scenario Outline: Check if Verify is working with Example Tables | ||
When I try Verify with Reqnroll for Parameter '<Parameter>' | ||
Then it works | ||
|
||
Examples: | ||
| Parameter | | ||
| 1 | | ||
| 2 | | ||
Scenario: Check if Verify is working | ||
When I try Verify with Reqnroll | ||
Then it works | ||
|
||
Scenario Outline: Check if Verify is working with Example Tables | ||
When I try Verify with Reqnroll for Parameter '<Parameter>' | ||
Then it works | ||
|
||
Examples: | ||
| Parameter | | ||
| 1 | | ||
| 2 | | ||
|
||
Scenario: Check if Verify is working with multiple scenario parameters | ||
When I try Verify with Reqnroll for Parameter '<Parameter>' and some additional parameter '<Additional Parameter>' | ||
Then it works | ||
|
||
Examples: | ||
| Parameter | Additional Parameter | | ||
| 1 | a | | ||
| 2 | b | | ||
|
||
Scenario: Check if Verify is working with global registered path info | ||
When I try Verify with Reqnroll with global registered path info | ||
Then it works |
6 changes: 6 additions & 0 deletions
6
...Verify/Reqnroll.Verify.ReqnrollPlugin.IntegrationTest/Features/Parallel Feature 1.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,6 @@ | ||
Feature: Verify Parallel feature #1 | ||
|
||
Scenario: Check if Verify uses the correct paths when ran in parallel 1 | ||
When I try Verify with Reqnroll in parallel | ||
Then it works in parallel with contents `Verify Parallel feature #1` | ||
And the verified file is `Verify Parallel feature #1.Check if Verify uses the correct paths when ran in parallel 1.verified.txt` with contents `Verify Parallel feature #1` |
6 changes: 6 additions & 0 deletions
6
...Verify/Reqnroll.Verify.ReqnrollPlugin.IntegrationTest/Features/Parallel Feature 2.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,6 @@ | ||
Feature: Verify Parallel feature #2 | ||
|
||
Scenario: Check if Verify uses the correct paths when ran in parallel 2 | ||
When I try Verify with Reqnroll in parallel | ||
Then it works in parallel with contents `Verify Parallel feature #2` | ||
And the verified file is `Verify Parallel feature #2.Check if Verify uses the correct paths when ran in parallel 2.verified.txt` with contents `Verify Parallel feature #2` |
1 change: 1 addition & 0 deletions
1
...lel feature #1.Check if Verify uses the correct paths when ran in parallel 1.verified.txt
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 @@ | ||
Verify Parallel feature #1 |
1 change: 1 addition & 0 deletions
1
...lel feature #2.Check if Verify uses the correct paths when ran in parallel 2.verified.txt
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 @@ | ||
Verify Parallel feature #2 |
1 change: 1 addition & 0 deletions
1
...ures/Verify Test.Check if Verify is working with global registered path info.verified.txt
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 @@ | ||
value |
1 change: 1 addition & 0 deletions
1
...Verify Test.Check if Verify is working with multiple scenario parameters_1_a.verified.txt
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 @@ | ||
1 .. a |
1 change: 1 addition & 0 deletions
1
...Verify Test.Check if Verify is working with multiple scenario parameters_2_b.verified.txt
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 @@ | ||
2 .. b |
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
8 changes: 8 additions & 0 deletions
8
Plugins/Reqnroll.Verify/Reqnroll.Verify.ReqnrollPlugin.IntegrationTest/reqnroll.json
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,8 @@ | ||
{ | ||
"$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json", | ||
"generator": { | ||
"addNonParallelizableMarkerForTags": [ | ||
"DoNotParallelize" | ||
] | ||
} | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Verify | ||
|
||
Reqnroll supports Verify 24.2.0 or later. | ||
|
||
Documentation for Verify can be found [here](https://github.com/VerifyTests/Verify). | ||
|
||
## Needed NuGet Packages | ||
|
||
* [Reqnroll.xUnit](https://www.nuget.org/packages/Reqnroll.xUnit/) and its [dependencies](xunit.md#Needed%20NuGet%20Packages) | ||
* [Reqnroll.Verify](https://www.nuget.org/packages/Reqnroll.Verify/) | ||
|
||
## How it works | ||
|
||
This plugin adds a VerifySettings instance to Reqnroll's scenario container, which can be used to set the correct path for the tests' verified files. | ||
|
||
### Example | ||
|
||
```Gherkin | ||
Feature: Verify feature | ||
Scenario: Verify scenario | ||
When I calculate 1 + 2 | ||
Then I expect the result is correct | ||
``` | ||
```csharp | ||
[Binding] | ||
internal class StepDefinitions | ||
{ | ||
private readonly VerifySettings _settings; | ||
|
||
public StepDefinitions(VerifySettings settings) | ||
{ | ||
_settings = settings; | ||
} | ||
|
||
[When("I calculate (\d+) + (\d+)")] | ||
public void WhenICalculate(int value, int value2) | ||
{ | ||
_settings.Verify(value + value, _settings); | ||
} | ||
|
||
[Then("I expect the result is correct")] | ||
public void ThenIExpectTheResultIsCorrect() | ||
{ | ||
} | ||
} | ||
|
||
``` | ||
|
||
**Note:** in a single-threaded environment, the plugin will work without the injected VerifySettings instance. However, in a multithreaded environment, the VerifySettings instance must be injected into the step definition class for a deterministic outcome. |