Open sandboxFocus

Property CancellationToken

CancellationToken

Gets the CancellationToken that the test must pass to the code under test. It is signalled when the timeout defined by Timeout elapses, or when the test framework cancels the test, whichever comes first.

Declaration
public CancellationToken CancellationToken { get; }
Property Value
Type Description
CancellationToken
Remarks

The cancellation of the test framework reaches this token through the token passed to the constructor. CreateTestContext(string?, string?) passes Xunit.TestContext.CancellationToken of Xunit.TestContext.Current, and the aspect test framework passes the token of the test run. Only the timeout writes a message to the test output and signals that the application is exiting.

When a debugger is attached, there is no timeout, because a test that runs under a debugger can legitimately run for a long time. The token is then the token passed to the constructor.