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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin" Version="2.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin" Version="2.4.1" />
                    
Directory.Packages.props
<PackageReference Include="Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin --version 2.4.1
                    
#r "nuget: Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin, 2.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin&version=2.4.1
                    
Install Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin as a Cake Addin
#tool nuget:?package=Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin&version=2.4.1
                    
Install Adrichem.ReqnrollPlugIn.RetryStep.ReqnrollPlugin as a Cake Tool

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:

  1. Complete when it runs successfully. This avoids unecessary delays.
  2. Retry when it throws during the allowable time.
  3. 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:

  1. Retrieve the IRetryStepPluginConfiguration from the ScenarioContainer and ask if the current BindingMatch should be retried.
  2. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.4.1 163 4/26/2025
2.4.0 201 4/18/2025