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

TestActionCommand

TestActionCommand handles a single ITestAction applied to a test. It runs the BeforeTest method, then runs the test and finally runs the AfterTest method.
using System.Runtime.CompilerServices; namespace NUnit.Framework.Internal.Commands { public class TestActionCommand : BeforeAndAfterTestCommand { [NullableContext(1)] public TestActionCommand(TestCommand innerCommand, ITestAction action) : base(innerCommand) { Guard.ArgumentValid(innerCommand.Test is TestMethod, "TestActionCommand may only apply to a TestMethod", "innerCommand"); Guard.ArgumentNotNull(action, "action"); BeforeTest = delegate { action.BeforeTest(base.Test); }; AfterTest = delegate { action.AfterTest(base.Test); }; } } }