<PackageReference Include="NUnit" Version="4.3.0" />

ParallelizableAttribute

Marks a test assembly, fixture or method that may be run in parallel.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using System; using System.Runtime.CompilerServices; namespace NUnit.Framework { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class ParallelizableAttribute : PropertyAttribute, IApplyToContext { public ParallelScope Scope { get; } public ParallelizableAttribute() : this(ParallelScope.Self) { } public ParallelizableAttribute(ParallelScope scope) { Scope = scope; base.Properties.Set("ParallelScope", scope); } [NullableContext(1)] public override void ApplyToTest(Test test) { if (test is TestFixture && Scope.HasFlag(ParallelScope.Fixtures)) base.Properties.Set("ParallelScope", Scope | ParallelScope.Self); base.ApplyToTest(test); if (test.RunState != 0) { if (Scope.HasFlag(ParallelScope.Self) && Scope.HasFlag(ParallelScope.None)) test.MakeInvalid("Test may not be both parallel and non-parallel"); else if (Scope.HasFlag(ParallelScope.Fixtures)) { if (test is TestMethod || test is ParameterizedMethodSuite) test.MakeInvalid("May not specify ParallelScope.Fixtures on a test method"); } else if (Scope.HasFlag(ParallelScope.Children) && test is TestMethod) { test.MakeInvalid("May not specify ParallelScope.Children on a non-parameterized test method"); } } } [NullableContext(1)] public void ApplyToContext(TestExecutionContext context) { context.ParallelScope = (Scope & ParallelScope.ContextMask); } } }