Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin
2.4.1
dotnet add package Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin --version 2.4.1
NuGet\Install-Package Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin -Version 2.4.1
<PackageReference Include="Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin" Version="2.4.1" />
<PackageVersion Include="Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin" Version="2.4.1" />
<PackageReference Include="Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin" />
paket add Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin --version 2.4.1
#r "nuget: Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin, 2.4.1"
#addin nuget:?package=Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin&version=2.4.1
#tool nuget:?package=Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin&version=2.4.1
A Reqnroll Proof Of Concept to retry failed steps
Why retry?
The System Under Test (SUT) runs asynchronously and needs time to reach the correct state. During this time the various Then
steps may not fail the scenario.
In essence execution of a single Then
step needs to:
- Complete when it runs successfully. This avoids unecessary delays.
- Retry when it throws during the allowable time.
- Stop and throw last exception when the maximum time is reached.
How the step definition author provides logic and decisions for retry
The author registers a IRetryStepPluginConfiguration
in the scenario container. This object has 1 method to decide if a BindingMatch
should be retried or not.
They also register a IAsyncRetryer
having the Task RetryAsync(Action)
method. This object is responsible for doing the retry logic.
For example:
//This test project wants all `Then` steps to be retried.
public class RetryThen : IRetryStepPluginConfiguration
{
public bool RetryEnabledFor(BindingMatch match) => match.StepBinding.StepDefinitionType == StepDefinitionType.Then;
}
[BeforeScenario]
public static void BeforeScenario(IObjectContainer c)
{
c.RegisterInstanceAs<IRetryStepPluginConfiguration>(new RetryThen());
c.RegisterInstanceAs<IAsyncRetryer>(new PollyRetryer());
}
[Then("this step definition will be retried in case of transient failures")]
public void DoCheck() => MySystem.State.Should().BeOK();
How the plugin is implemented
The plugin registers a custom ITestExecutionEngine
. This custom engine derives from the default ReqnRoll TestExecutionEngine
but overrides the ExecuteStepMatchAsync
method to:
- Retrieve the
IRetryStepPluginConfiguration
from the ScenarioContainer and ask if the currentBindingMatch
should be retried. - If retry is needed, it retrieves an
IAsyncRetryer
from the ScenarioContainer to perform the retry logic on the invocation of the binding like this
await Retryer.RetryAsync(async () => await _bindingInvoker.InvokeBindingAsync(match.StepBinding, _contextManager, arguments, _testTracer, durationHolder));
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Reqnroll (>= 2.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.