3

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.

Dayan54
  • 31
  • 3

2 Answers2

1

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

JeffC
  • 22,180
  • 5
  • 32
  • 55
  • For any other tests I'd do this. but I'm using Specflow. not sure how this applies in that case – Dayan54 Apr 08 '19 at 08:40
  • You tagged your question with [nunit]... are you not using NUnit? – JeffC Apr 08 '19 at 16:24
  • 1
    Yes but I'm also using specflow. which do not allow me to simply add [Parallelizable(ParallelScope.None)] for a single test in the same way as if I was not using specflow. I was trying to findout wether or not I could do this is some other way – Dayan54 Apr 09 '19 at 14:00
0

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

Sandesh A D
  • 162
  • 2
  • 12