Running Specflow test in Parallel using Specflow 2.0 and NUnit 3.x

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

5 comments

  1. Ravi Teja says:

    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. Jo says:

    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. Raj says:

    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 ?

    • Karthik kk says:

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

      Thanks,
      Karthik KK

Leave a Reply

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