-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Execution Context (AsyncLocal) does not get transferred between [BeforeScenario] and the steps. #120
Comments
@GedasFX Could you please also make a commit where you use the latest beta of SpecFlow (4.0.31-beta) to see how the behavior was there? |
@gasparnagy GedasFX/AsyncLocal_ReqNRoll@9feaa24 it's Its failing on 4.0.31-beta... |
@GedasFX Thx. So this is a side effect of switching the testing to full async in SpecFlow v4. I remember that is was pretty tricky with the AsyncLocal and the execution context, but I don't remember all the details now. Fortunately there is a bunch of tests on the current behavior (https://github.com/reqnroll/Reqnroll/blob/main/Tests/Reqnroll.RuntimeTests/Bindings/BindingInvokerTests.cs#L268). If you have a bit of time, you can review those tests, maybe it helps understanding the problem, but I can also look at that next week. |
Oh I guess you guys sort of figured it out :D planned to check today ^^ |
Reqnroll Version
1.0.1
Which test runner are you using?
xUnit
Test Runner Version Number
2.6.5
.NET Implementation
.NET 8.0
Test Execution Method
ReSharper Test Runner
Content of reqnroll.json configuration file
No response
Issue Description
I have a setup in our tests where we have a service provider which generates services, and each of our tests is arranged as a separate request (scope). We also have some default value prefilling on before scenario (actual logic is more complex, but for sake of example it can be simplified).
The issue here is when we use IHttpContextAccessor, a singleton service, it internally uses AsyncLocal to keep track of the HTTP context. On Specflow, the assigned context in BeforeScenario, can be seen later in the service, however when using reqnroll, it cannot.
Steps to Reproduce
Successful commit (specflow): GedasFX/AsyncLocal_ReqNRoll@99c0c50
Failing commit (reqnroll): GedasFX/AsyncLocal_ReqNRoll@d444e22
Checkout the commits. There is a single test in the test suite.
Link to Repro Project
https://github.com/GedasFX/AsyncLocal_ReqNRoll
The text was updated successfully, but these errors were encountered: