Table of Contents

Class XunitTestRunnerBaseContext<TTest>

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

Context class for XunitTestRunner.

public class XunitTestRunnerBaseContext<TTest> : TestRunnerContext<TTest>, IAsyncLifetime, IAsyncDisposable where TTest : class, IXunitTest

Type Parameters

TTest
Inheritance
XunitTestRunnerBaseContext<TTest>
Implements
Derived
Inherited Members

Constructors

XunitTestRunnerBaseContext(TTest, IMessageBus, ExplicitOption, ExceptionAggregator, CancellationTokenSource, IReadOnlyCollection<IBeforeAfterTestAttribute>, object?[])

Initializes a new instance of the XunitTestRunnerBaseContext<TTest> class.

public XunitTestRunnerBaseContext(TTest test, IMessageBus messageBus, ExplicitOption explicitOption, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource, IReadOnlyCollection<IBeforeAfterTestAttribute> beforeAfterTestAttributes, object?[] constructorArguments)

Parameters

test TTest

The test

messageBus IMessageBus

The message bus to send execution messages to

explicitOption ExplicitOption

The user's choice on how to treat explicit tests

aggregator ExceptionAggregator

The exception aggregator

cancellationTokenSource CancellationTokenSource

The cancellation token source

beforeAfterTestAttributes IReadOnlyCollection<IBeforeAfterTestAttribute>

The IBeforeAfterTestAttributes that are applied to the test

constructorArguments object[]

The constructor arguments for the test class

Properties

BeforeAfterTestAttributes

Gets the collection of IBeforeAfterTestAttribute used for this test.

public IReadOnlyCollection<IBeforeAfterTestAttribute> BeforeAfterTestAttributes { get; }

Property Value

IReadOnlyCollection<IBeforeAfterTestAttribute>

ConstructorArguments

Gets the arguments that should be passed to the test class when it's constructed.

public object?[] ConstructorArguments { get; }

Property Value

object[]

Methods

GetSkipReason(Exception?)

Gets the runtime skip reason for the test, inspecting the provided exception to see if it contractually matches a "dynamically skipped" exception (that is, any exception message that starts with Value). If the exception does not match the pattern, consults the base skip reason (from Skip), as well as SkipUnless and SkipWhen to determine if the test should be dynamically skipped.

public override string? GetSkipReason(Exception? exception)

Parameters

exception Exception

The exception to inspect

Returns

string

The skip reason, if the test is skipped; null, otherwise

RunAfterAttributes()

Runs the After(MethodInfo, IXunitTest) side of the before after attributes.

public void RunAfterAttributes()

RunBeforeAttributes()

Runs the Before(MethodInfo, IXunitTest) side of the before after attributes.

public void RunBeforeAttributes()