Table of Contents

Method CreateTestClassInstance

Namespace
Xunit.v3
Assembly
xunit.v3.core.dll

CreateTestClassInstance(TContext)

Override to creates and initialize the instance of the test class.

protected override ValueTask<(object? Instance, SynchronizationContext? SyncContext, ExecutionContext? ExecutionContext)> CreateTestClassInstance(TContext ctxt)

Parameters

ctxt TContext

The context that describes the current test

Returns

ValueTask<(object Instance, SynchronizationContext SyncContext, ExecutionContext ExecutionContext)>

Returns the test class instance, the sync context that is current after the creation, and a capture of the execution context so that it can be restored later.

Remarks

This method runs during Running and any exceptions thrown will contribute to test failure. Since the method is potentially async, we depend on it to capture and return the sync context so that it may be propagated appropriately.