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

BeforeTestCommand

public abstract class BeforeTestCommand : DelegatingTestCommand
BeforeTestCommand is a DelegatingTestCommand that performs some specific action before the inner command is run.
using System; using System.Runtime.CompilerServices; namespace NUnit.Framework.Internal.Commands { [System.Runtime.CompilerServices.NullableContext(1)] [System.Runtime.CompilerServices.Nullable(0)] public abstract class BeforeTestCommand : DelegatingTestCommand { [System.Runtime.CompilerServices.Nullable(new byte[] { 2, 1 })] protected Action<TestExecutionContext> BeforeTest; public BeforeTestCommand(TestCommand innerCommand) : base(innerCommand) { } public override TestResult Execute(TestExecutionContext context) { Guard.OperationValid(BeforeTest != null, "BeforeTest was not set by the derived class constructor"); BeforeTest(context); return context.CurrentResult = innerCommand.Execute(context); } } }