Reqnroll Version
2.4.1
Which test runner are you using?
MSTest
Test Runner Version Number
dotnet test, Visual Studio Test Explorer 2022
.NET Implementation
.NET 9.0
Test Execution Method
Visual Studio Test Explorer
Content of reqnroll.json configuration file
{
"$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",
"bindingAssemblies": [
]
}
Issue Description
❗️ Problem summary
After migrating from SolidToken.SpecFlow.DependencyInjection to Reqnroll.Microsoft.Extensions.DependencyInjection, we noticed that [ScenarioDependencies(ScopeLevelType.Scenario)] is only invoked once per test run, not per scenario.
This breaks the expected behavior where each scenario should receive a freshly built IServiceProvider.
This issue occurs:
⚠️ Impact
-
💣 Breaks test isolation
-
🧪 Prevents reseeding in-memory databases (duplicate key errors)
-
🔧 Makes it impossible to vary mocks or services between scenarios
-
🐛 Inconsistent with the documentation and intended purpose of ScopeLevelType.Scenario
✅ Expected behavior
[ScenarioDependencies(ScopeLevelType.Scenario)] should be executed once per scenario, with a fresh IServiceProvider or ILifetimeScope built each time.
💬 Additional notes
This behavior works correctly under SolidToken.SpecFlow.DependencyInjection.
Steps to Reproduce
🔄 Steps to reproduce
Create a test project with Reqnroll + Microsoft.Extensions.DependencyInjection plugin
Add [ScenarioDependencies(ScopeLevel = ScopeLevelType.Scenario)] on a method
Add Console.WriteLine(...) inside the method
Create a .feature file with 2+ scenarios
Run with dotnet test or from Test Explorer
💥 Result:
CreateServices() is only called once — the same ServiceProvider is reused across all scenarios.
Link to Repro Project
No response
Reqnroll Version
2.4.1
Which test runner are you using?
MSTest
Test Runner Version Number
dotnet test, Visual Studio Test Explorer 2022
.NET Implementation
.NET 9.0
Test Execution Method
Visual Studio Test Explorer
Content of reqnroll.json configuration file
{
"$schema": "https://schemas.reqnroll.net/reqnroll-config-latest.json",
"bindingAssemblies": [
]
}
Issue Description
❗️ Problem summary
After migrating from
SolidToken.SpecFlow.DependencyInjectiontoReqnroll.Microsoft.Extensions.DependencyInjection, we noticed that[ScenarioDependencies(ScopeLevelType.Scenario)]is only invoked once per test run, not per scenario.This breaks the expected behavior where each scenario should receive a freshly built
IServiceProvider.This issue occurs:
In Visual Studio
With
dotnet testEven when the method is annotated properly with
ScopeLevelType.Scenario💣 Breaks test isolation
🧪 Prevents reseeding in-memory databases (duplicate key errors)
🔧 Makes it impossible to vary mocks or services between scenarios
🐛 Inconsistent with the documentation and intended purpose of
ScopeLevelType.Scenario✅ Expected behavior
[ScenarioDependencies(ScopeLevelType.Scenario)]should be executed once per scenario, with a freshIServiceProviderorILifetimeScopebuilt each time.💬 Additional notes
This behavior works correctly under
SolidToken.SpecFlow.DependencyInjection.Steps to Reproduce
🔄 Steps to reproduce
Create a test project with Reqnroll + Microsoft.Extensions.DependencyInjection plugin
Add [ScenarioDependencies(ScopeLevel = ScopeLevelType.Scenario)] on a method
Add Console.WriteLine(...) inside the method
Create a .feature file with 2+ scenarios
Run with dotnet test or from Test Explorer
💥 Result:
CreateServices() is only called once — the same ServiceProvider is reused across all scenarios.
Link to Repro Project
No response