Closed konarx closed 9 months ago
@konarx Which version of SpecFlow did you use before migrating?
I was able to reproduce the issue. I think this was an issue already in SpecFlow v4 beta, but I am waiting for your confirmation on that.
The problem is that the IObjectContainer
you get in the [BeforeTestRun]
hook should be the "global container", but for some reason the "test thread container" is injected instead. For some other reason (I'm not sure if this is OK), the scenario and the related [BeforeScenario]
hook is running in another test thread so it does not "see" the registrations you made on the container.
This has to be fixed.
Workaround: The workaround is to get the "base container" of the "test thread container" in the [BeforeTestRun]
hook. So you need to change the line in the BeforeTestRun
method from:
_objectContainer = objectContainer;
to
_objectContainer = ((ObjectContainer)objectContainer).BaseContainer;
(this workaround needs to be reverted once the issue is fixed)
Thank you @gasparnagy, the suggested workaround does the trick indeed. I can proceed with the migration now.
It is fixed now by #59 and will be included in the next release. In the meantime please use the workaround.
Reqnroll Version
1.0.1
Which test runner are you using?
NUnit
Test Runner Version Number
4.5.0
.NET Implementation
.NET 6.0
Test Execution Method
ReSharper Test Runner
Content of reqnroll.json configuration file
Issue Description
I am using Rider with the latest build of the Rider.Reqnroll plugin. I have two .cs files for Hooks,
TestRunLevelHooks
:and
ScenarioLevelHooks
:I execute a test using Test Explorer in Rider and getting the following error:
The issue started after migrate to Reqnroll using the namespace changes method. It was not reproduced when using SpecFlow and I have kept the same dependency injection methods.
Here is the
.csproj
(if it matters):Steps to Reproduce
When debugging, I managed to see that the
[BeforeTestRun]
executed successfully, registering all objects to the_objectContainer
. The error occurs in theScenarioLevelHooks
.Link to Repro Project
No response