Class XunitRunnerHelper
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
messageBusIMessageBusThe message bus to send the messages to
cancellationTokenSourceCancellationTokenSourceThe cancellation token source to cancel if requested
testITestThe test to fail
exceptionExceptionThe exception to fail the test cases with
Returns
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
messageBusIMessageBusThe message bus to send the messages to
cancellationTokenSourceCancellationTokenSourceThe cancellation token source to cancel if requested
testCasesIReadOnlyCollection<ITestCase>The test cases to fail
exceptionExceptionThe exception to fail the test cases with
sendTestCollectionMessagesboolSet to
trueto send ITestCollectionStarting and ITestCollectionFinished messages; set tofalseto skipsendTestClassMessagesboolSet to
trueto send ITestClassStarting and ITestClassFinished messages; set tofalseto skipsendTestMethodMessagesboolSet to
trueto send ITestMethodStarting and ITestMethodFinished messages; set tofalseto skipsendTestCaseMessagesboolSet to
trueto send ITestCaseStarting and ITestCaseFinished messages; set tofalseto skipsendTestMessagesboolSet to
trueto send ITestStarting and ITestFinished messages; set tofalseto skip
Returns
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
messageBusIMessageBusThe message bus to send the messages to
cancellationTokenSourceCancellationTokenSourceThe cancellation token source to cancel if requested
testCasesIReadOnlyCollection<ITestCase>The test cases to fail
messageFormatstringA message template where
{0}will be replaced with the display name of the test case during failure processingsendTestCollectionMessagesboolSet to
trueto send ITestCollectionStarting and ITestCollectionFinished messages; set tofalseto skipsendTestClassMessagesboolSet to
trueto send ITestClassStarting and ITestClassFinished messages; set tofalseto skipsendTestMethodMessagesboolSet to
trueto send ITestMethodStarting and ITestMethodFinished messages; set tofalseto skipsendTestCaseMessagesboolSet to
trueto send ITestCaseStarting and ITestCaseFinished messages; set tofalseto skipsendTestMessagesboolSet to
trueto send ITestStarting and ITestFinished messages; set tofalseto skip
Returns
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
testCaseIXunitTestCaseThe test case to run
messageBusIMessageBusThe message bus to send the messages to
cancellationTokenSourceCancellationTokenSourceThe cancellation token source to cancel if requested
aggregatorExceptionAggregatorThe exception aggregator to record exceptions to
explicitOptionExplicitOptionA flag to indicate which types of tests to run (non-explicit, explicit, or both)
constructorArgumentsobject[]The arguments to pass to the test class constructor
Returns
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
messageBusIMessageBusThe message bus to send the messages to
cancellationTokenSourceCancellationTokenSourceThe cancellation token source to cancel if requested
testCasesIReadOnlyCollection<ITestCase>The test cases to fail
skipReasonstringThe skip reason
sendTestCollectionMessagesboolSet to
trueto send ITestCollectionStarting and ITestCollectionFinished messages; set tofalseto skipsendTestClassMessagesboolSet to
trueto send ITestClassStarting and ITestClassFinished messages; set tofalseto skipsendTestMethodMessagesboolSet to
trueto send ITestMethodStarting and ITestMethodFinished messages; set tofalseto skipsendTestCaseMessagesboolSet to
trueto send ITestCaseStarting and ITestCaseFinished messages; set tofalseto skipsendTestMessagesboolSet to
trueto send ITestStarting and ITestFinished messages; set tofalseto skip