Table of Contents

Class XunitRunnerHelper

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

Helper functions for xUnit.net v3 runners.

public static class XunitRunnerHelper
Inheritance
XunitRunnerHelper
Inherited Members

Methods

FailTest(IMessageBus, CancellationTokenSource, ITest, Exception)

Fail a test with the given exception.

public static RunSummary FailTest(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource, ITest test, Exception exception)

Parameters

messageBus IMessageBus

The message bus to send the messages to

cancellationTokenSource CancellationTokenSource

The cancellation token source to cancel if requested

test ITest

The test to fail

exception Exception

The exception to fail the test cases with

Returns

RunSummary

FailTestCases(IMessageBus, CancellationTokenSource, IReadOnlyCollection<ITestCase>, Exception, bool, bool, bool, bool, bool)

Fail a set of test cases with the given exception.

public static RunSummary FailTestCases(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource, IReadOnlyCollection<ITestCase> testCases, Exception exception, bool sendTestCollectionMessages = false, bool sendTestClassMessages = false, bool sendTestMethodMessages = false, bool sendTestCaseMessages = true, bool sendTestMessages = true)

Parameters

messageBus IMessageBus

The message bus to send the messages to

cancellationTokenSource CancellationTokenSource

The cancellation token source to cancel if requested

testCases IReadOnlyCollection<ITestCase>

The test cases to fail

exception Exception

The exception to fail the test cases with

sendTestCollectionMessages bool

Set to true to send ITestCollectionStarting and ITestCollectionFinished messages; set to false to skip

sendTestClassMessages bool

Set to true to send ITestClassStarting and ITestClassFinished messages; set to false to skip

sendTestMethodMessages bool

Set to true to send ITestMethodStarting and ITestMethodFinished messages; set to false to skip

sendTestCaseMessages bool

Set to true to send ITestCaseStarting and ITestCaseFinished messages; set to false to skip

sendTestMessages bool

Set to true to send ITestStarting and ITestFinished messages; set to false to skip

Returns

RunSummary

FailTestCases(IMessageBus, CancellationTokenSource, IReadOnlyCollection<ITestCase>, string, bool, bool, bool, bool, bool)

Fail a set of test cases with the given message.

public static RunSummary FailTestCases(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource, IReadOnlyCollection<ITestCase> testCases, string messageFormat, bool sendTestCollectionMessages = false, bool sendTestClassMessages = false, bool sendTestMethodMessages = false, bool sendTestCaseMessages = true, bool sendTestMessages = true)

Parameters

messageBus IMessageBus

The message bus to send the messages to

cancellationTokenSource CancellationTokenSource

The cancellation token source to cancel if requested

testCases IReadOnlyCollection<ITestCase>

The test cases to fail

messageFormat string

A message template where {0} will be replaced with the display name of the test case during failure processing

sendTestCollectionMessages bool

Set to true to send ITestCollectionStarting and ITestCollectionFinished messages; set to false to skip

sendTestClassMessages bool

Set to true to send ITestClassStarting and ITestClassFinished messages; set to false to skip

sendTestMethodMessages bool

Set to true to send ITestMethodStarting and ITestMethodFinished messages; set to false to skip

sendTestCaseMessages bool

Set to true to send ITestCaseStarting and ITestCaseFinished messages; set to false to skip

sendTestMessages bool

Set to true to send ITestStarting and ITestFinished messages; set to false to skip

Returns

RunSummary

RunXunitTestCase(IXunitTestCase, IMessageBus, CancellationTokenSource, ExceptionAggregator, ExplicitOption, object?[])

Runs a single test case (which implements IXunitTestCase) using the XunitTestCaseRunner after enumerating all tests.

public static ValueTask<RunSummary> RunXunitTestCase(IXunitTestCase testCase, IMessageBus messageBus, CancellationTokenSource cancellationTokenSource, ExceptionAggregator aggregator, ExplicitOption explicitOption, object?[] constructorArguments)

Parameters

testCase IXunitTestCase

The test case to run

messageBus IMessageBus

The message bus to send the messages to

cancellationTokenSource CancellationTokenSource

The cancellation token source to cancel if requested

aggregator ExceptionAggregator

The exception aggregator to record exceptions to

explicitOption ExplicitOption

A flag to indicate which types of tests to run (non-explicit, explicit, or both)

constructorArguments object[]

The arguments to pass to the test class constructor

Returns

ValueTask<RunSummary>

SkipTestCases(IMessageBus, CancellationTokenSource, IReadOnlyCollection<ITestCase>, string, bool, bool, bool, bool, bool)

Skips a set of test cases with the given skip reason.

public static RunSummary SkipTestCases(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource, IReadOnlyCollection<ITestCase> testCases, string skipReason, bool sendTestCollectionMessages = false, bool sendTestClassMessages = false, bool sendTestMethodMessages = false, bool sendTestCaseMessages = true, bool sendTestMessages = true)

Parameters

messageBus IMessageBus

The message bus to send the messages to

cancellationTokenSource CancellationTokenSource

The cancellation token source to cancel if requested

testCases IReadOnlyCollection<ITestCase>

The test cases to fail

skipReason string

The skip reason

sendTestCollectionMessages bool

Set to true to send ITestCollectionStarting and ITestCollectionFinished messages; set to false to skip

sendTestClassMessages bool

Set to true to send ITestClassStarting and ITestClassFinished messages; set to false to skip

sendTestMethodMessages bool

Set to true to send ITestMethodStarting and ITestMethodFinished messages; set to false to skip

sendTestCaseMessages bool

Set to true to send ITestCaseStarting and ITestCaseFinished messages; set to false to skip

sendTestMessages bool

Set to true to send ITestStarting and ITestFinished messages; set to false to skip

Returns

RunSummary