reqnroll / Reqnroll

Open-source Cucumber-style BDD test automation framework for .NET.
https://reqnroll.net
BSD 3-Clause "New" or "Revised" License
310 stars 32 forks source link

Resolve BeforeTestRun/AfterTestRun hook dependencies from the test run (global) container instead of the test thread container #59

Closed gasparnagy closed 4 months ago

gasparnagy commented 4 months ago

Fixing #58.

So far the [BeforeTestRun] / [AfterTestRun] hooks were resolved from the "first" test run context. This is pretty arbitrary and misleading. They should have been resolved from the test run ("global") context.

This normally should not matter for single-threaded tests, but it seems that the way how SpecFlow v4 (and Reqnroll) invokes these hooks is different and they are not necessarily invoked from the same test thread that is used for test execution (this depends on the test execution framework probably, but with NUnit there seem to be a different thread), so anything that you register in [BeforeTestRun] to the injected container might not be visible for the step definitions or scenario hooks.

This PR changes this and resolves the [BeforeTestRun] / [AfterTestRun] hooks from the test run ("global") context. This means that some services that were available so far for these hooks are not available anymore (e.g. "IReqnrollOutputHelper"), let's see the impact of this.

Types of changes

Checklist: