Does NUnit 3.x support parallel execution?Yes it does, NUnit parallel execution support is discussed in greater details in Selenium automation with C# video series of ExecuteAutomation youtube channel
Parallel execution considerationIn order to achieve parallel test execution, there are some important consideration needed to be taken care before you ensure your test runs properly Parallel execution with memory isolation (AppDomain)
- Ensure your test code executing the application is not depends on static states (e.g. external cache, databases etc), if so then
- This can be achieved by isolating test into AppDomain, this ensures that every test execution thread is hosted in a separate AppDomain and that each thread’s memory
- If your tests do not depend on any static states (ie. do not store any test-specific information in static fields), you can run the tests in parallel without AppDomain isolation
What’s the code change in existing specflow code ?It’s fairly very simple, just one line of additional change in AssemblyInfo.cs file and you are good to go and the change is this
Here is the complete video of the above discussion Thanks for reading the post and watching the video!!! Please leave your comments and let me know if there is anything I should update in this post. Thanks, Karthik KK
9 Replies to “Running Specflow test in Parallel using Specflow 2.0 and NUnit 3.x”
Does the same approach work for MsTest?
Could you please help me in running specflow tests using specRunner through command line not using visual studio to run my tests.
Thank you for the video Karthik. How about executing on multiple browsers in parallel with Specflow? SauceLabs or other cloud services are the only option?
This is a very good method. I am having a challenge here. I am having Page Objects classes and I need to pass the drivers from Steps to Pages or maintain ScenarioContext. I indeed checked the AppDomain., but still I am getting static message error. Could you please help me in this ?
Can you paste the code snippet and error you are getting to better troubleshoot the problem
It is possible, implement a parallel execution by features?
Thanks for the info. My automation script has some static fields. Can you please tell me how to run tests in parallel with Memory isolation?
When I try to run Parallel execution for your ‘SpecflowParalleTest’ project that is available at github/executeAutomation site, I am getting following error message after setting ‘[assembly: Parallelizable(ParallelScope.Fixtures)]’ in AssemblyInfo file
Message: OneTimeSetUp: TechTalk.SpecFlow.SpecFlowException : The FeatureContext.Current static accessor cannot be used in multi-threaded execution. Try injecting the feature context to the binding class. See http://go.specflow.org/doc-multithreaded for details.
I have looked over ‘http://specflow.org/documentation/Parallel-Execution/’ but I am still having trouble understanding how to actually add this to the framework. Could you please help me to resolve this issue?
Please let me know if you require any more information/clarification
You can disable the Parallelizable attribute from Assemby.info file