Table of Contents

Delegate FixtureFactory

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

Describes a fixture factory function.

public delegate ValueTask<object?> FixtureFactory(FixtureMappingManager? parentMappingManager, bool forceCreation)

Parameters

parentMappingManager

The parent mapping manager, if there is one

forceCreation bool

A flag to indicate creation should be forced

Returns

ValueTask<object>

The fixture if it was created, or else returns null.

Remarks

The forceCreation flag is used to indicate that the fixture should always be created; this will be true during initialization if fixture pre-creation is requested, and during any call to FixtureMappingManager to get the actual fixture value. The factory should use a false value to determine whether to create the fixture based on whether it's decorated with INotifyLifecycle, in which case we need to ensure the fixture gets created even for cases where it wouldn't normally get created (for example, when used in a static test class) so that the fixture can subscribe to test lifecycle events.

This logic is left to the fixture factory, since the source generator should be able to make this decision without resorting to reflection.