Issue with ThreadStatic/AsyncLocal Variables Being Set to Null After Migrating from SpecFlow to Reqnroll (Playwright, NUnit) #469
Replies: 1 comment
-
SpecFlow (v3) was not really async. It used a hack to run the async hooks and step definitions from a sync context. SpecFlow v4 (never released) introduced real async handling and that (naturally) changed the behavior. In my opinion, using the So primarily I recommend to remove these constructs and build up the infrastructure without them. Using Following the logic of that, you cannot set an Reqnroll has a more correct async implementation now. As I wrote in the issue, you can study the related tests in Reqnroll: As I also wrote there, what you can do is to initialize the I hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Previously posted here: #428
I've tried to migrate to the suggested solution, using AsyncLocal variables however this gave me the same issue as when using ThreadStatic where the variables would be set to null as the thread has been killed. Ideally I don't want to be passing these variables down to my steps, pages and components for everything and wondered if there might be another solution on how to resolve this? As this isn't an issue when using SpecFlow, it's making the migration path to Reqnroll difficult.
The ThreadStatic variables are used for the BrowserContext, Browser, ActivePage as an example of their uses and are used to differentiate between each NUnit thread when ran in parallel execution.
Technology Used: .NET, Playwright, NUnit
Description:
I recently migrated from SpecFlow to Reqnroll using the provided migration guide. However, after running a test, I encountered an issue where the ThreadStatic or AsyncLocal variables, which are initialized using the BeforeFeature hook, are being set to null. This problem only arose after the migration.
I have tried both the compatibility migration and namespace migration, but the issue persists.
Details:
Steps to Reproduce
Beta Was this translation helpful? Give feedback.
All reactions