Interface ITestContext
- Namespace
- Xunit
- Assembly
- xunit.v3.core.dll
Represents the current state of the test pipeline.
public interface ITestContext
- Extension Methods
-
Xunit.TestContextExtensions.GetFixture``1(Xunit.ITestContext)
Properties
- Attachments
Gets the attachments for the current test, if the engine is currently in the process of running a test; will return null outside of the context of a test.
- CancellationToken
Gets the cancellation token that is used to indicate that the test run should be aborted. Async tests should pass this along to any async functions that support cancellation tokens, to help speed up the cancellation process.
- KeyValueStorage
Stores key/value pairs that are available across all stages of the pipeline. Can be used to communicate between extensions at different execution stages, in both directions, as a single storage container is used for the entire pipeline.
- PipelineStage
Gets the current test pipeline stage.
- Test
Gets the current test, if the engine is currently in the process of running a test; will return null outside of the context of a test.
- TestAssembly
Gets the current test assembly, if the engine is currently in the process of running or discovering tests in assembly; will return null out of this context (this typically means the test framework itself is being created and initialized).
- TestAssemblyStatus
Gets the current test engine status for the test assembly.
- TestCase
Gets the current test case, if the engine is currently in the process of running a test case; will return null outside of the context of a test case.
- TestCaseStatus
Gets the current test engine status for the test case. Will only be available when TestCase is not null.
- TestClass
Gets the current test method, if the engine is currently in the process of running a test class; will return null outside of the context of a test class. Note that not all test framework implementations require that tests be based on classes, so this value may be null even if TestCase is not null.
- TestClassInstance
Gets the instance of the test class; will return null outside of the context of a test. Static test methods do not create test class instances, so this will always be null for static test methods.
- TestClassStatus
Gets the current test engine status for the test class. Will only be available when TestClass is not null.
- TestCollection
Gets the current test collection, if the engine is currently in the process of running a test collection; will return null outside of the context of a test collection.
- TestCollectionStatus
Gets the current test engine status for the test collection. Will only be available when TestCollection is not null.
- TestMethod
Gets the current test method, if the engine is currently in the process of running a test method; will return null outside of the context of a test method. Note that not all test framework implementations require that tests be based on methods, so this value may be null even if TestCase is not null.
- TestMethodStatus
Gets the current test engine status for the test method. Will only be available when TestMethod is not null.
- TestOutputHelper
Gets the output helper, which can be used to add output to the test. Will only be available when Test is not null. Note that the value may still be null when Test is not null, if the test framework implementation does not provide output helper support.
- TestState
Gets the current state of the test. Will only be available after the test has finished running.
- TestStatus
Gets the current test engine status for the test. Will only be available when Test is not null.
- Warnings
Gets the set of warnings associated with the current test. Will only be available when Test is not null; will also return null if there have been no warnings issued.
Methods
- AddAttachment(string, byte[], bool, string)
Adds an attachment that is a binary value (represented by a byte array and media type).
- AddAttachment(string, byte[], string)
Adds an attachment that is a binary value (represented by a byte array and media type).
- AddAttachment(string, string)
Adds an attachment that is a string value.
- AddAttachment(string, string, bool)
Adds an attachment that is a string value.
- AddWarning(string)
Adds a warning to the test result.
- CancelCurrentTest()
Attempt to cancel the currently executing test, if one is executing. This will signal the CancellationToken for cancellation.
- GetFixture(Type)
Gets a fixture that was attached to the test class. Will return null if there is no exact match for the requested fixture type, or if there is no test class (that is, if TestClass returns null).
- SendDiagnosticMessage(string)
Sends a diagnostic message. Will only be visible if the end user has enabled diagnostic messages. See https://xunit.net/docs/configuration-files for configuration information.
- SendDiagnosticMessage(string, object?)
Sends a formatted diagnostic message. Will only be visible if the end user has enabled diagnostic messages. See https://xunit.net/docs/configuration-files for configuration information.
- SendDiagnosticMessage(string, object?, object?)
Sends a formatted diagnostic message. Will only be visible if the end user has enabled diagnostic messages. See https://xunit.net/docs/configuration-files for configuration information.
- SendDiagnosticMessage(string, object?, object?, object?)
Sends a formatted diagnostic message. Will only be visible if the end user has enabled diagnostic messages. See https://xunit.net/docs/configuration-files for configuration information.
- SendDiagnosticMessage(string, params object?[])
Sends a formatted diagnostic message. Will only be visible if the end user has enabled diagnostic messages. See https://xunit.net/docs/configuration-files for configuration information.