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

TestActionItem

public class TestActionItem
TestActionItem wraps a single execution of an ITestAction. Its primary purpose is to track whether the BeforeTest method has been called and suppress calling the AfterTest method if it has not. This is necessary when ITestActions are used before and after a CompositeWorkItem, since the OneTimeSetUpCommand and OneTimeTearDownCommand are separate command chains. By sharing a TestActionItem between the setup and teardown chains, the two calls can be coordinated.
public bool BeforeTestWasRun { get; }

Get flag indicating if the BeforeTest entry was already called.

public TestActionItem(ITestAction action)

Construct a TestActionItem

public void AfterTest(ITest test)

Run the AfterTest action, but only if the BeforeTest action was actually run.

public void BeforeTest(ITest test)

Run the BeforeTest method of the action and remember that it has been run.