E2ESetupAttribute
Namespace: E2E.NUnit
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]public sealed class E2ESetupAttribute : TestAttribute, IImplyFixture, ISimpleTestBuilder, IApplyToTest, 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 [Test], and Title is the test’s 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 [SetUp] and [TearDown] methods; 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. NUnit then skips that setup test
when its turn comes, and still runs one that no selected test needs, which upstream’s runner does not. The setup test gets an early
[Order], so it runs before the other tests of its own fixture.
</p>
Inheritance: object → Attribute → NUnitAttribute → TestAttribute
Implements: IImplyFixture, ISimpleTestBuilder, IApplyToTest, ISessionSetup
Constructors
Section titled “Constructors”E2ESetupAttribute(string)
Section titled “E2ESetupAttribute(string)”public E2ESetupAttribute(string title)Creates a setup test named <code class=“paramref”>title</code>.
Parameters
| Name | Type | Description |
|---|---|---|
title |
string |
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
Methods
Section titled “Methods”ApplyToTest(Test)
Section titled “ApplyToTest(Test)”public void ApplyToTest(Test test)Gives the test an early order unless it has one, and refuses a setup test that saves nothing.
Parameters
| Name | Type | Description |
|---|---|---|
test |
Test |
BuildFrom(IMethodInfo, Test?)
Section titled “BuildFrom(IMethodInfo, Test?)”public TestMethod BuildFrom(IMethodInfo method, Test? suite)Names the test and builds it. Only the name is the title: the full name stays the method’s, so it is unique and filters keep working.
Parameters
| Name | Type | Description |
|---|---|---|
method |
IMethodInfo |
|
suite |
Test |
Returns: TestMethod