Site Loader
Auckland, New Zealand
In this post we will discuss one of the cool new feature introduced by Specflow 2.0, which is Parallel execution support out-of-box along with NUnit 3.x.

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 consideration

In 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
Parallel execution without memory isolation (AppDomain)
  • 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

Post Author: Karthik kk

9 Replies to “Running Specflow test in Parallel using Specflow 2.0 and NUnit 3.x”

  1. Hi Karthik,

    Could you please help me in running specflow tests using specRunner through command line not using visual studio to run my tests.

    Thanks,
    Ravi Teja.

  2. 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?

  3. Hi Karthik,

    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 ?

    1. Can you paste the code snippet and error you are getting to better troubleshoot the problem

      Thanks,
      Karthik KK

  4. Hi Karthik,
    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?

  5. Hi Karthik,

    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

Leave a Reply to Niraj Patel Cancel reply

Your email address will not be published. Required fields are marked *