Corvus.Testing.Reqnroll
5.0.3
dotnet add package Corvus.Testing.Reqnroll --version 5.0.3
NuGet\Install-Package Corvus.Testing.Reqnroll -Version 5.0.3
<PackageReference Include="Corvus.Testing.Reqnroll" Version="5.0.3" />
<PackageVersion Include="Corvus.Testing.Reqnroll" Version="5.0.3" />
<PackageReference Include="Corvus.Testing.Reqnroll" />
paket add Corvus.Testing.Reqnroll --version 5.0.3
#r "nuget: Corvus.Testing.Reqnroll, 5.0.3"
#:package Corvus.Testing.Reqnroll@5.0.3
#addin nuget:?package=Corvus.Testing.Reqnroll&version=5.0.3
#tool nuget:?package=Corvus.Testing.Reqnroll&version=5.0.3
Corvus.Testing.Reqnroll
Bindings that make Reqnroll specs easier to write:
- Container bindings: a dependency injection container for each scenario or each feature, which is built, made available to your steps, and disposed for you.
- Child objects: refer to objects stored in the scenario context from Reqnroll tables, with
{name}. - Teardown exception handling: run every
After...binding even when some fail, and report all the failures together at the end.
Requires .NET 10 and Reqnroll 3.
Getting started
If you use NUnit or MSTest, install the metapackage for your test framework. It brings in this package along with Reqnroll, the test adapter and the test SDK:
dotnet add package Corvus.Testing.Reqnroll.NUnit
dotnet add package Corvus.Testing.Reqnroll.MSTest
Otherwise, install this package on its own:
dotnet add package Corvus.Testing.Reqnroll
Then tell Reqnroll to load the bindings, in your test project's reqnroll.json:
{
"$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",
"stepAssemblies": [
{ "assembly": "Corvus.Testing.Reqnroll" }
]
}
Container bindings
Tag a scenario (or a whole feature) with @perScenarioContainer, or a feature with @perFeatureContainer. Then add services in a binding that runs at the right point:
[BeforeScenario("@perScenarioContainer", Order = ContainerBeforeScenarioOrder.PopulateServiceCollection)]
public static void PopulateServices(ScenarioContext scenarioContext)
{
ContainerBindings.ConfigureServices(scenarioContext, services =>
services.AddSingleton<IStore, FakeStore>());
}
Get services in any step:
IServiceProvider serviceProvider = ContainerBindings.GetServiceProvider(this.scenarioContext);
IStore store = serviceProvider.GetRequiredService<IStore>();
For per-feature containers, use [BeforeFeature], ContainerBeforeFeatureOrder and the FeatureContext instead. The service provider is disposed when the scenario or feature ends.
Child objects
With the @useChildObjects tag, a table value in braces is replaced with the object stored in the scenario context under that name. This works with Reqnroll's table helpers, such as CreateInstance and CreateSet:
@useChildObjects
Scenario: Create a team
Given I have stored a person as 'alice'
When I create a team from this table
| Name | Leader |
| Red | {alice} |
Team team = table.CreateInstance<Team>(); // team.Leader is the object stored as "alice"
Teardown exception handling
Reqnroll stops running After... bindings as soon as one throws. Wrap teardown work in RunAndStoreExceptions (or RunAndStoreExceptionsAsync) so that the exception is stored and the remaining bindings still run:
[AfterScenario]
public void DeleteTestResources()
{
this.scenarioContext.RunAndStoreExceptions(() => this.resources.DeleteAll());
}
At the end of the scenario or feature, all the stored exceptions are thrown together as one AggregateException. There are overloads for both ScenarioContext and FeatureContext.
More information
- Full documentation, including binding order and custom tags
- Changelog
- Source code and issues
Corvus.Testing.Reqnroll is maintained by endjin and licensed under Apache 2.0.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Configuration.Abstractions (>= 10.0.15)
- Microsoft.Extensions.DependencyInjection (>= 10.0.15)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 10.0.15)
- Reqnroll (>= 3.3.4)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on Corvus.Testing.Reqnroll:
| Package | Downloads |
|---|---|
|
Corvus.Testing.AzureFunctions.ReqnRoll
Integration framework that enables behavior-driven development (BDD) testing of Azure Functions using ReqnRoll (formerly SpecFlow). Provides utilities for programmatically starting, configuring, and stopping Azure Functions instances during test execution, with seamless ReqnRoll integration for writing human-readable test specifications. Supports both In-Process and Isolated Azure Functions models. |
|
|
Corvus.Testing.Reqnroll.NUnit
A metapackage that references everything needed to write Reqnroll specs with NUnit and Corvus.Testing.Reqnroll: Reqnroll.NUnit, NUnit3TestAdapter, Microsoft.NET.Test.Sdk, coverlet.msbuild and Microsoft.Extensions.DependencyInjection. Updating this one package keeps them all in step. |
|
|
Corvus.Testing.Reqnroll.MSTest
A metapackage that references everything needed to write Reqnroll specs with MSTest and Corvus.Testing.Reqnroll: Reqnroll.MSTest, MSTest, Microsoft.NET.Test.Sdk, coverlet.msbuild and Microsoft.Extensions.DependencyInjection. Updating this one package keeps them all in step. |
|
|
Corvus.Testing.CosmosDb.Reqnroll
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.