NUnit
<PackageReference Include="Tracera.NUnit" Version="*" />
Requires .NET ≥ 8 and NUnit ≥ 4 (see Autotest adapters). Tracera.NUnit on NuGet.
Environment variables, run mode, and retries: Autotest adapters.
Retry Env key: NUNIT_RETRY.
Prefer an assembly attribute so the adapter can finish the run it created when the suite ends. A class-level attribute alone still uploads results, but finishing the run may then wait until the process exits:
[assembly: TraceraNUnit]
[TraceraNUnit] // optional on a test class when the assembly attribute is present
public class LoginTests
{
// …
}
Bind testCaseId and autotestName
Use stock NUnit APIs and the global Tracera type.
At declaration (preferred — bind runs even if the body skips early):
using NUnit.Framework;
[assembly: TraceraNUnit]
public class LoginTests
{
[Test]
[Tracera.Id(42, name: "e2e/login")]
public void Login()
{
Assert.That(true);
}
}
Inside the test:
[Test]
public void Login()
{
Tracera.TestCase(42, "e2e/login");
Assert.That(true);
}
Skip
Use stock NUnit skip (Assert.Ignore, Assert.Inconclusive, [Ignore], …). The skip reason is added to the result as comment.
Steps
Use Tracera.Step("…", () => { … }), Tracera.Step("…", async () => { … }) (async lambdas are awaited), or put [Tracera.Step("…")] on a method (sync and async Task). With [Tracera.Step], if the title is empty or omitted, the step title becomes the method name; {0} / {name} in the title are filled from the method arguments. Steps inside [SetUp] / [TearDown] go to the result’s Setup / Teardown; steps inside the test go to Test. [OneTimeSetUp] / [OneTimeTearDown] steps are not reported; if OneTimeSetUp fails, declaratively bound tests still report Failed (empty steps, setup error on the result).
using NUnit.Framework;
[assembly: TraceraNUnit]
public class CheckoutTests
{
[SetUp]
public void OpenShop()
{
Tracera.Step("open shop", () => { });
}
[Tracera.Step("add {sku}")]
public void AddSku(string sku) { }
[Test]
[Tracera.Id(10, name: "e2e/checkout")]
public void Checkout()
{
AddSku("SKU-1");
Tracera.Step("pay", () => { });
}
}
Comments, errors, and attachments
Comments, errors, and attachments: Autotest adapters.
Tracera.Comment("result-level note");
Tracera.Error("result-level error text");
Tracera.Step("open login", () =>
{
Tracera.Comment("landed on login");
});
Parameterized tests
Put [Tracera.Id] on each [TestCase] / [TestCaseSource] method (same id for every row, or call Tracera.TestCase inside when the id varies). Optional name may include placeholders: {login} (and other argument names) from the method parameters, or {param_id} for the NUnit test name (in the example below, Login("ok") / Login("sso")). If name is omitted, autotestName takes the value of the NUnit test name.
[Tracera.Id(42, name: "login as {login}")]
[TestCase("ok")]
[TestCase("sso")]
public void Login(string login)
{
Assert.That(login, Is.Not.Empty);
}