Reputation: 1
Is there any way to execute code before and after each specific thread when executing tests in parallel with SharedAppDomain thread isolation in Specflow?
I was using BeforeTestRun/AfterTestRun Hooks for this purpose, but it seems that since last Specflow versions this is only possible when running tests "AppDomain" thread isolation, and in SharedAppDomain isolation it runs only once per test.
Upvotes: 0
Views: 388
Reputation: 3117
If you are running your tests in parallel, each thread will represent a running scenario. To run something after each scenario you can use the AfterScenario
hook.
BeforeTestRun/AfterTestRun are for the entire test run where multiple threads may be running. They are designed to run once for all threads but I have found AfterTestRun
to be patchy. Sometimes it appears unable to determine that the last running thread has finished before entering AfterTestRun
.
Upvotes: 0