Precept
Precept is a test framework for .NET 10, built on Microsoft.Testing.Platform (MTP). It comes with its own test runner and with the modules an end-to-end suite needs.
Precept implements MTP's ITestFramework interface. That means Precept controls how tests are discovered, scheduled, retried and reported, while the platform makes them run under dotnet test, dotnet run, IDE test explorers and TRX reporting. On top of the runner, Precept ships the pieces an end-to-end suite normally has to assemble by hand: HTTP clients, browsers, databases, gRPC, containers, test data, per-environment configuration, and reporting to ReportPortal, Teams and Azure DevOps.
A test is a C# class with attributes. Gherkin is optional: add Precept.Reqnroll and Reqnroll compiles your .feature files into the same attributed classes.
C# classes with [TestSuite] / [Test] .feature files ── optional, via Precept.Reqnroll
│ │ Reqnroll parser + Precept.Reqnroll.Generator
│ │ emit the same attributed classes
└──────────────┬─────────────┘
│ Precept.TestPlatform (ITestFramework)
▼
Microsoft.Testing.Platform → dotnet test / IDE / TRX
Start here#
- InstallingWhich package to reference, a complete test project, and the one line
global.jsonneeds. - Project templates
dotnet new precept-web— a suite that already has environments and a first test. - Writing testsGherkin scenarios, plain C# tests, the attributes, and the outcomes a test can report.
- AssertionsOne awaited shape for a value in hand, an element not on the page yet, and a job that finishes eventually.
What a test looks like#
[TestSuite("Checkout")]
[TestCategory("smoke")]
public class CheckoutTests
{
[Test("A customer can check out")]
[Retry(2, DelayMilliseconds = 200)]
public async Task Checkout()
{
var response = await Rest.Post("/orders")
.WithJsonBody(new { sku = "ABC", quantity = 2 })
.SendAsync();
await Assert.That(response).ToHaveStatusAsync(HttpStatusCode.Created);
await Assert.That(response).ToHaveJsonValueAsync("status", "created");
}
}
With Precept.Reqnroll referenced, the same suite written in Gherkin compiles to the same class. In
the test explorer, "Go to test" opens the Scenario: line of the .feature file rather than the
generated code. See writing tests and
test explorer navigation.
What comes with it#
| Module | What it adds |
|---|---|
Precept.Reqnroll |
Gherkin: .feature files compiled into Precept test classes. |
Precept.Api |
A fluent HTTP client and response assertions, logged into the test's report. |
Precept.Web |
Playwright, isolated per scenario, capturing screenshots, traces and video on failure. |
Precept.Screenplay |
The screenplay pattern over those modules: actors, abilities, interactions and questions. |
Precept.Data |
Provider-agnostic ADO.NET for seeding and asserting against a database. |
Precept.TestData |
Environment-specific data sets, generated values, factories, and pooled records. |
Precept.Files |
Excel, CSV, JSON and XML files written from a data table, read back as rows, and asserted on. |
Precept.Grpc |
Pooled channels, typed clients, and assertions over status codes and streaming. |
Precept.Containers |
Docker dependencies for a run, overridable by configuration. |
| Reporting | ReportPortal, Teams and Azure DevOps test cases, off the test's thread. |
Every module depends only on Precept.Core and is registered from one
startup class. Nothing is on unless a suite asks for it. Two modules are shaped
differently: Precept.Reqnroll adds MSBuild targets rather than services, and Precept.Screenplay
sits on top of the other modules rather than beside them. Both are ways of writing a suite, not
things to register.
How a run is put together#
- Configuration —
precept.json, overlays, and settings of your own. - Environments — how one is chosen, and how to switch from an IDE without editing a file.
- Execution model — what runs in parallel, and why a high
MaxParallelismcan look ignored. - Filtering — selecting a subset, and removing tests from an environment entirely.
- Artifacts and logging — what reaches a TRX, a test explorer and a report.
- Running a suite on CI — a complete Azure Pipelines example.