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

PlatformAttribute

PlatformAttribute is used to mark a test fixture or an individual method as applying to a particular platform only.
using NUnit.Framework.Interfaces; using NUnit.Framework.Internal; using System; namespace NUnit.Framework { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = false)] public class PlatformAttribute : IncludeExcludeAttribute, IApplyToTest { private PlatformHelper platformHelper = new PlatformHelper(); public PlatformAttribute() { } public PlatformAttribute(string platforms) : base(platforms) { } public void ApplyToTest(Test test) { if (test.RunState != 0 && test.RunState != RunState.Ignored) { bool flag = false; try { flag = platformHelper.IsPlatformSupported(this); } catch (InvalidPlatformException ex) { test.RunState = RunState.NotRunnable; test.Properties.Add("_SKIPREASON", ex.Message); return; } if (!flag) { test.RunState = RunState.Skipped; test.Properties.Add("_SKIPREASON", platformHelper.Reason); } } } } }