await operation in step causing thread switching(from a managed thread to thread pool thread) when using reqnroll while specflow continues to execute using same managed thread #563
Unanswered
satishmarisetti123
asked this question in
SpecFlow migration Q&A
Replies: 2 comments 1 reply
-
@satishmarisetti123 I've updated your post because of some code was unreadable. Could you please fix the indentation and maybe, post a smaller test case. Its not really a minimal example. |
Beta Was this translation helpful? Give feedback.
1 reply
-
this is the nature of async/await that there is no really a guarantee which thread executes the code after an await. What is your goal with having Thread Specific Object Container? Why is this not stored in the FeatureContext or ScenarioContext? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
We are currently migrating from specflow to reqnroll. Specflow tests are configured to use "Nunit" as test execution framework and run in parallell(Parallelizable(ParallelScope.Fixtures).
Existing implementation:
BeforeTestRun hook: Registering CustomValueComparerRetriever(Implementation of IValueRetriever,IValueComparer) with reqnroll.assisst.Service.
BeforeFeature hook: creates an entry in dictionary object with threadId and objectcontainer for every execution of hook.
please see below for code samples.
CustomValueRetrieverComparer
While invoking Table.CreateInstance() method from a step, assist.service is invoking canretrieve on the customvaluecomparerretriever which is fetching objectcontainer related to the current feature passing the currentmanagedThreadId to dictionary(created in beforeFeaturehook) it worked fine in specflow but after migrating to reqnroll thread executing the canretrieve of customValueComparerRetriever is different from thread executing the beforefeature hook.Hence we are not able to get objectcontainer of current feature hence not able to create instance from table.
Note:There is an await call in one of the steps which causing the switch from managed thread(that executed beforefeaturehook) to a threadpool thread to takeover the subsequent execution whereas same await operation when used with specflow did not cause switching to a threadpool thread. I am assuming this switching is internal to .NET asyn/await implementation but I am wondering why this is not happening any time while using specflow.
Can you please help me how to deal with this problem or change the implementation for reqnroll?
Beta Was this translation helpful? Give feedback.
All reactions