E2ETest
Namespace: E2E.TUnit
[TestExecutor<LooksBeforeTeardownExecutor>]public abstract class E2ETest : E2EFixture, ITestEndEventReceiver, IEventReceiverBase class for a TUnit test that drives the app. A before-test hook starts one engine session.
An after-test hook commits the replay cache from the TUnit result: a pass or a skip records
verified acts, a failure evicts the unverified ones it recorded or replayed, and a cancelled test
leaves the cache alone. A derived [After(Test)] hook that throws fails the test, and the cache sees that failure: the commit
runs when TUnit ends the test, because the result holds the hook’s failure only then. The first attempt can replay. [Retry] attempts run live and still
record. TUnit builds one instance per test, so the session lives on the instance.
Each Expect.Soft failure is kept on the session. The test body runs on, and the test
fails when its after-test hook runs, with every soft failure in one message.
Settings come from E2EFixture.
Inheritance: object → E2EFixture
Implements: ITestEndEventReceiver, IEventReceiver
Properties
Section titled “Properties”public int Order { get; }Runs after every hook, when the test result holds what a derived [After(Test)] hook threw: the verdict is the test body’s, the soft
failures’, or the result’s own, and then the session is completed and disposed.
Value: int
SessionStartToken
Section titled “SessionStartToken”protected CancellationToken SessionStartToken { get; }.NET-only: the cancellation token of the before-test hook that starts the session (TUnit’s hook timeout and the run’s cancellation). CreateEngine() runs inside that hook and can wait on it, so a subclass that blocks there passes this token, not the test’s.
Value: CancellationToken
public EventReceiverStage Stage { get; }Runs after every hook, when the test result holds what a derived [After(Test)] hook threw: the verdict is the test body’s, the soft
failures’, or the result’s own, and then the session is completed and disposed.
Value: EventReceiverStage
Methods
Section titled “Methods”CacheTitle(TestContext)
Section titled “CacheTitle(TestContext)”protected virtual string CacheTitle(TestContext test)The test’s title: its cache identity, and the Test: line every prompt’s context opens with.
The default is the class and method name, with every argument in full, so each test and
each data row keeps its own replay. The TUnit display name is not used, because a display name
can be changed by an attribute or shortened for long arguments.
Parameters
| Name | Type | Description |
|---|---|---|
test |
TestContext |
Returns: string
FinishE2ESessionAsync(TestContext, CancellationToken)
Section titled “FinishE2ESessionAsync(TestContext, CancellationToken)”[After(HookType.Test)]public Task FinishE2ESessionAsync(TestContext context, CancellationToken cancellationToken)The base class hook runs after the derived ones, so a teardown has run. It collects the soft failures and a handler failure
the teardown left, and hands the session to OnTestEnd(TestContext): TUnit sets the test result, which holds a failure of a
derived [After(Test)] hook, only after every hook has run.
Parameters
| Name | Type | Description |
|---|---|---|
context |
TestContext |
|
cancellationToken |
CancellationToken |
Returns: Task
OnTestEnd(TestContext)
Section titled “OnTestEnd(TestContext)”public ValueTask OnTestEnd(TestContext context)Runs after every hook, when the test result holds what a derived [After(Test)] hook threw: the verdict is the test body’s, the soft
failures’, or the result’s own, and then the session is completed and disposed.
Parameters
| Name | Type | Description |
|---|---|---|
context |
TestContext |
Returns: ValueTask
StartE2ESessionAsync(TestContext, CancellationToken)
Section titled “StartE2ESessionAsync(TestContext, CancellationToken)”[Before(HookType.Test)]public Task StartE2ESessionAsync(TestContext context, CancellationToken cancellationToken)Parameters
| Name | Type | Description |
|---|---|---|
context |
TestContext |
|
cancellationToken |
CancellationToken |
Returns: Task