-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Could not load System.CodeDom exception with xRetry.Reqnroll plu…
…gin (#316) * Fix: Could not load System.CodeDom exception with xRetry.Reqnroll plugin (#310) * update CHANGELOG.md * improve infra to load binding files from resource * use test files from resource * Fix Linux CI
- Loading branch information
1 parent
76cabee
commit bd11612
Showing
7 changed files
with
104 additions
and
2 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
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,41 @@ | ||
using FluentAssertions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using Reqnroll.TestProjectGenerator; | ||
using Reqnroll.TestProjectGenerator.Driver; | ||
using System.Linq; | ||
|
||
namespace Reqnroll.SystemTests.Plugins; | ||
|
||
[TestClass] | ||
public class XRetryPluginTest : SystemTestBase | ||
{ | ||
protected override void TestInitialize() | ||
{ | ||
base.TestInitialize(); | ||
_testRunConfiguration.UnitTestProvider = UnitTestProvider.xUnit; | ||
_projectsDriver.AddNuGetPackage("xRetry.Reqnroll", "1.0.0"); | ||
} | ||
|
||
[TestMethod] | ||
public void XRetry_should_work_with_Reqnroll() | ||
{ | ||
AddFeatureFileFromResource("XRetryPlugin/XRetryPluginTestFeature.feature"); | ||
AddBindingClassFromResource("XRetryPlugin/XRetryPluginTestStepDefinitions.cs"); | ||
|
||
ExecuteTests(); | ||
|
||
ShouldAllScenariosPass(); | ||
|
||
var simulatedErrors = _bindingDriver.GetActualLogLines("simulated-error").ToList(); | ||
simulatedErrors.Should().HaveCount(_preparedTests * 2); // two simulated error per test | ||
} | ||
|
||
[TestMethod] | ||
[TestCategory("MsBuild")] | ||
public void XRetry_should_work_with_Reqnroll_on_DotNetFramework_generation() | ||
{ | ||
// compiling with MsBuild forces the generation to run with .NET Framework | ||
_compilationDriver.SetBuildTool(BuildTool.MSBuild); | ||
XRetry_should_work_with_Reqnroll(); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
Tests/Reqnroll.SystemTests/Resources/XRetryPlugin/XRetryPluginTestFeature.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,15 @@ | ||
Feature: XRetryPluginFeature | ||
|
||
Used by Reqnroll.SystemTests.Plugins.XRetryPluginTest | ||
|
||
@retry | ||
Scenario: Scenario with Retry | ||
When fail for first 2 times A | ||
|
||
@retry | ||
Scenario Outline: Scenario outline with Retry | ||
When fail for first 2 times <label> | ||
Examples: | ||
| label | | ||
| B | | ||
| C | |
26 changes: 26 additions & 0 deletions
26
Tests/Reqnroll.SystemTests/Resources/XRetryPlugin/XRetryPluginTestStepDefinitions.cs
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,26 @@ | ||
// Used by Reqnroll.SystemTests.Plugins.XRetryPluginTest | ||
using System.Collections.Generic; | ||
namespace XRetryPluginTest.StepDefinitions | ||
{ | ||
[Binding] | ||
public class XRetryPluginTestStepDefinitions | ||
{ | ||
private static readonly Dictionary<string, int> RetriesByLabel = new Dictionary<string, int>(); | ||
|
||
[When("fail for first {int} times {word}")] | ||
public void WhenFailForFirstTwoTimes(int retryCount, string label) | ||
{ | ||
if (!RetriesByLabel.TryGetValue(label, out var retries)) | ||
{ | ||
retries = 0; | ||
} | ||
var failTest = retries < retryCount; | ||
RetriesByLabel[label] = ++retries; | ||
if (failTest) | ||
{ | ||
Log.LogCustom("simulated-error", label); | ||
throw new Exception($"simulated error for {label}"); | ||
} | ||
} | ||
} | ||
} |
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