-
Notifications
You must be signed in to change notification settings - Fork 46
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 (#310)
- Loading branch information
1 parent
7c22e2f
commit 3695956
Showing
2 changed files
with
95 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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() | ||
{ | ||
AddScenario( | ||
""" | ||
@retry | ||
Scenario: Scenario with Retry | ||
When fail for first 2 times A | ||
"""); | ||
AddScenario( | ||
""" | ||
@retry | ||
Scenario Outline: Scenario outline with Retry | ||
When fail for first 2 times <label> | ||
Examples: | ||
| label | | ||
| B | | ||
| C | | ||
"""); | ||
AddBindingClass( | ||
""" | ||
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}"); | ||
} | ||
} | ||
} | ||
} | ||
"""); | ||
|
||
ExecuteTests(); | ||
|
||
ShouldAllScenariosPass(); | ||
|
||
var simulatedErrors = _bindingDriver.GetActualLogLines("simulated-error").ToList(); | ||
simulatedErrors.Should().HaveCount(_preparedTests * 2); // two simulated error per test | ||
} | ||
|
||
[TestMethod] | ||
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(); | ||
} | ||
} |