Table of Contents

Method SetForTest

Namespace
Xunit
Assembly
xunit.v3.core.dll

SetForTest(ITest, TestEngineStatus, CancellationToken, TestResultState?, ITestOutputHelper?, object?)

Sets the test context for execution of a test. This assumes an existing test context already exists from which it can pull the diagnostic and internal diagnostic message sinks.

public static void SetForTest(ITest test, TestEngineStatus testStatus, CancellationToken cancellationToken, TestResultState? testState = null, ITestOutputHelper? testOutputHelper = null, object? testClassInstance = null)

Parameters

test

The test that is being executed

testStatus

The test status (valid values: Initializing, Running, and CleaningUp)

cancellationToken CancellationToken

The cancellation token used to cancel execution

testState

The state of the test (only required when testStatus is CleaningUp).

testOutputHelper

The test output helper that the test can use to write output. Must be passed when testStatus is Initializing; can be null for other statuses (as it will be pulled from the existing test context).

testClassInstance object

The instance of the test class (may be null for static class and before the test class has been created)