Precept 0.14.0

Precept.TestData

Test data management for Precept: environment-specific data sets for the users, clients, vehicles and anything else a suite needs, generated values, factories that create and clean up data in the system under test, and pooled records leased to one test at a time.

dotnet add package Precept.TestData
services.AddPreceptTestData();
// testdata.json, beside the test binary
{
  "users": {
    "admin": { "username": "admin@acme.test", "password": "{{env:ADMIN_PASSWORD}}" }
  },
  "clients": {
    "new": { "name": "Acme {{unique}}", "email": "acme-{{unique}}@acme.test" }
  }
}
var admin = TestData.Get<TestUser>("admin");
var password = TestData.Value("users:admin:password");

testdata.json is overlaid by testdata.{environment}.json and then by PRECEPT_TESTDATA__* environment variables. That is how a password reaches a run without being written down in the repository.

Values may carry tokens such as {{unique}}, {{run}}, {{guid}}, {{now:+2d}}, {{date:-80y:-18y}}, {{decimal:1.00-99.99}} and {{pick:red|green|blue}}. They are expanded when a value is read, so a suite that inserts the same email address on every run stops failing on the second one. {{unique}} is the same value throughout a scenario, so every step sees what the first one created, and a retry generates a fresh one. TestData.Resolve expands tokens in a string that came from a feature file, and Resolve<T> reads the result as a number or a date.

The module's types live in the root Precept namespace, so a step definition needs no further using.

A coding agent can get all of this, checked against the project in front of it, from precept_explain_testdata in Precept.Mcp.


Part of Precept, a .NET 10 test framework built on Microsoft.Testing.Platform. Full documentation: test data · dynamic values · factories · pooled data · from Gherkin

Precept 0.14.0 · MIT · © 2026

Esc