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

ParallelizableAttribute

ParallelizableAttribute is used to mark tests that may be run in parallel.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using System; namespace NUnit.Framework { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = true)] public class ParallelizableAttribute : PropertyAttribute, IApplyToContext { private ParallelScope _scope; public ParallelizableAttribute() : this(ParallelScope.Self) { } public ParallelizableAttribute(ParallelScope scope) { _scope = scope; base.Properties.Add("ParallelScope", scope); } public override void ApplyToTest(Test test) { 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"); if (test is TestMethod && _scope.HasFlag(ParallelScope.ContextMask)) test.MakeInvalid("ParallelScope of a test method may not specify Children or Fixtures"); } } public void ApplyToContext(TestExecutionContext context) { context.ParallelScope = (_scope & ParallelScope.ContextMask); } } }