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

TestActionAttribute

public abstract class TestActionAttribute : Attribute, ITestAction
Abstract attribute providing actions to execute before and after tests.
using NUnit.Framework.Interfaces; using System; using System.Runtime.CompilerServices; namespace NUnit.Framework { [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method | AttributeTargets.Interface, AllowMultiple = true, Inherited = true)] public abstract class TestActionAttribute : Attribute, ITestAction { public virtual ActionTargets Targets => ActionTargets.Default; [System.Runtime.CompilerServices.NullableContext(1)] public virtual void BeforeTest(ITest test) { } [System.Runtime.CompilerServices.NullableContext(1)] public virtual void AfterTest(ITest test) { } } }