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

WorkItem

public abstract class WorkItem
A WorkItem may be an individual test case, a fixture or a higher level grouping of tests. All WorkItems inherit from the abstract WorkItem class, which uses the template pattern to allow derived classes to perform work in whatever way is needed. A WorkItem is created with a particular TestExecutionContext and is responsible for re-establishing that context in the current thread before it begins or resumes execution.
public TestExecutionContext Context { get; }

The execution context

public ITestFilter Filter { get; }

Filter used to include or exclude child tests

public virtual string Name { get; }

The name of the work item - defaults to the Test name.

public ParallelScope ParallelScope { get; }

Gets the ParallelScope associated with the test, if any, otherwise returning ParallelScope.Default;

public TestResult Result { get; protected set; }

The test result

public WorkItemState State { get; }

Gets the current state of the WorkItem

public Test Test { get; }

The test being executed by the work item

public TestWorker TestWorker { get; }

The worker executing this item.

public event EventHandler Completed

Event triggered when the item is complete

public WorkItem(Test test, ITestFilter filter)

Construct a WorkItem for a particular test.

public WorkItem(WorkItem wrappedItem)

Construct a work Item that wraps another work Item. Wrapper items are used to represent independently dispatched tasks, which form part of the execution of a single test, such as OneTimeTearDown.

protected List<SetUpTearDownItem> BuildSetUpTearDownList(MethodInfo[] setUpMethods, MethodInfo[] tearDownMethods)

Builds the set up tear down list.

public virtual void Cancel(bool force)

Cancel (abort or stop) a WorkItem

protected void ChangeResult(ResultState resultState, string message)

Changes the result of the test, logging the old and new states

public virtual void Execute()

Execute the current work item, including any child work items.

Initialize the TestExecutionContext. This must be done before executing the WorkItem.

public void MarkNotRunnable(string reason)

Marks the WorkItem as NotRunnable.

protected abstract void PerformWork()

Method that performs actually performs the work. It should set the State to WorkItemState.Complete when done.

protected void WorkItemComplete()

Method called by the derived class when all work is complete