Dayan54
Dayan54

Reputation: 41

How to exclude some features/scenarios from parallel run?

I have a test solution using Specflow, selenium, NUnit running in parallel added this in AssemblyInfo: [assembly: Parallelizable(ParallelScope.Fixtures)]

everything ran nicely in parallel, but now I added a feature with a couple of scenarios that are not compatible with all the rest. So I'd like for them to run in separate.

Is there anyway to do this?

NOTE: I know about "[NonParallelizable]" I just don't know how to apply it since I'm using specflow.

Upvotes: 4

Views: 2352

Answers (2)

Sandesh A D
Sandesh A D

Reputation: 172

You need to add [Parallelizable(ParallelScope.None)] for your feature.cs file. You can do it manually but when you build your solution this change will be overwritten.

In MsTestV2 we can exclude the scenarios from parallel execution by adding a tag "@mstest:donotparallelize". Not sure about nUnit

  • Feature=Class
  • Scenario=Method

Below is the settings file

<?xml version="1.0" encoding="utf-8"?>
<RunSettings>
  <!-- Path to Test Adapters Use for mstest v2-->
  <TestAdaptersPaths>.\</TestAdaptersPaths>
  <MSTest>
    <Parallelize>
      <Workers>4</Workers>
      <Scope>Class</Scope>
    </Parallelize>
  </MSTest>
</RunSettings>

Now add the tag to feature file which you don't want to execute in parallel.

@mstest:donotparallelize
Feature: Calculator
    In order to avoid silly mistakes
    As a math idiot
    I want to be told the sum of two numbers

This will add [Microsoft.VisualStudio.TestTools.UnitTesting.DoNotParallelize()] attribute in feature.cs file

Upvotes: 0

JeffC
JeffC

Reputation: 25542

You should be able to decorate the specific tests that you want to exclude from parallel runs with either [NonParallelizable] or the equivalent [Parallelizable(ParallelScope.None)].

See the docs

Upvotes: 2

Related Questions