E2ESetupAttribute
Namespace: E2E.XUnit.V3
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]public sealed class E2ESetupAttribute : FactAttribute, IFactAttribute, ISessionSetupMarks a test of an E2ETest class as a setup test that saves sessions. Upstream’s test.setup(title, { sessions }, fn).
It is a test: it takes the place of [Fact], and Title is the test’s display name. Its body signs in and calls
SaveSessionAsync once for each name in Saves; a name saved twice, a name not declared, or a declared name left
unsaved fails the test with SESSION_CONTRACT. The sessions are saved when the test passes. A test that restores one is marked
E2ESessionAttribute.
<p>
A test that restores a session nobody has saved yet runs the setup test that declares it first, once per run, so a dependent can run
alone (upstream’s runner schedules the setup too). The dependent runs it on a new instance of the class (parameterless constructor), in a
session of its own and without the class’s own InitializeAsync and DisposeAsync; exactly one setup test of the assembly must
declare the name, or the restore fails with SESSION_UNAVAILABLE, as it does when the setup fails. xUnit then skips that setup test
when its turn comes, and still runs one that no selected test needs, which upstream’s runner does not. E2ETest runs the setup
tests of a class before its other tests (SetupTestMethodOrderer).
</p>
Inheritance: object → Attribute → FactAttribute
Implements: IFactAttribute, ISessionSetup
Constructors
Section titled “Constructors”E2ESetupAttribute(string, string?, int)
Section titled “E2ESetupAttribute(string, string?, int)”public E2ESetupAttribute(string title, string? sourceFilePath = null, int sourceLineNumber = -1)Creates a setup test named <code class=“paramref”>title</code>.
Parameters
| Name | Type | Description |
|---|---|---|
title |
string | |
sourceFilePath |
string | |
sourceLineNumber |
int |
Properties
Section titled “Properties”public string[] Saves { get; init; }The names of the sessions this test saves. At least one.
Value: string[]
public string Title { get; }The test’s name.
Value: string