Thursday, 16 July 2015

Parallel Testing with Nunit for SpecFlow(Selenium C#)

Agenda for this blog: To achieve Parallel Testing using NUnit for SpecFlow- Cucumber for .NET.

Why we need parallel testing :  There are several use of Parallel testing,In case of Selenium, parallel testing gives us many benefits like:



    • Cross -browser testing.
    • Less execution time (as the script gets segregated )
    • Testing with Different platforms using GRID many more.


Does NUnit supports Parallel testing : The answer to this question in a single word is NO.
Till date it does not support parallel testing in true way ,but there are way we can achieve parallel execution with NUnit by creating category and with the help of NUnit console

How to Do:



  • Step1: Create category in Feature file:  In Spec-flow which is a BDD framework from Selenium C# we need to create feature file and write the test case in ENGLISH-LIKE language called Gherkin,there in every feature file we need to mention "@CategoryName"


NOTE: Here @CategoryName can be anything relevant like @SmokeTest or @RegressionTest or  @SuiteName.

                      Now when you build your project you can see category wise segregation in the  Test Explorer in Visual Studio.


  • Step2:  Create a Batch file and call project .dll(compiled code) file for test execution mentioning categories by using nunit-console like:



nunit-console /result:TestResults1.xml pathToDllFile /include:CategoryName1
nunit-console /result:TestResults2.xml pathToDllFile /include:CategoryName2
nunit-console /result:TestResults3.xml pathToDllFile /include:CategoryName3


You will able to see parallel execution by category wise with multiple browser instances.


Visit for More Automation Related Discussion:

https://www.youtube.com/channel/UCKSk4gkmO3LXcW17hFUkmcQ/videos