Skip to main content

Installation

Create a small API and a working integration test suite with the template. Run the commands in order:

Start from the template​

The template creates a small ASP.NET Core API and a suite for it. The default starter needs the .NET 10 SDK.

dotnet new install ProtoTest.Templates
dotnet new prototest -n Shop
cd Shop
dotnet test

The run passes. The test project leaves Shop.Tests/bin/Debug/net10.0/TestResults/prototest-{runId}.prototrace and Shop.html. Each run writes its own trace, so a rerun never overwrites the previous one. Open the report for the run's verdict and the routes it covered, or drop the trace on trace.prototest.dev.

ProtoTest ships as small NuGet packages: your runner package, ProtoTest.Core, and one package per integration you use. The runner and integration packages target .NET 8, 9 and 10. ProtoTest.Cli targets .NET 8 only. ProtoTest.Analyzers and ProtoTest.Templates are netstandard2.0.

The suite is written for NUnit. Pass --runner xunit, --runner xunit3, --runner tunit or --runner mstest to generate it for another runner, and --framework net8.0 or --framework net9.0 to target an older framework.

What the template creates​

Two projects, one setup file picked by the runner, and four order scenarios against a tiny API:

Shop/
├── Shop.slnx
├── global.json # xunit3 and tunit only: the Microsoft.Testing.Platform opt-in
├── README.md
├── Shop.Api/
│ ├── Shop.Api.csproj
│ ├── Program.cs # POST /api/orders, GET /api/orders/{id}, in-memory store
│ └── Orders.cs # NewOrder, Order, OrderStore
└── Shop.Tests/
├── Shop.Tests.csproj # the runner package plus AspNetCore, Rest, Reporting
├── Setup.cs # hosts the API in-process, registers REST, tracing, the HTML report
└── OrderTests.cs # four tests: create, read back, validation, not found

Setup.cs starts as Setup.{runner}.cs and is renamed for the runner you picked. The test project always adds ProtoTest.AspNetCore, ProtoTest.Rest and ProtoTest.Reporting next to the runner package; TUnit also sets OutputType to Exe, as TUnit requires.

FlagValuesDefault
--runnernunit, xunit, xunit3, tunit, mstestnunit
--frameworknet10.0, net9.0, net8.0net10.0

Next: Your first test walks the same path one step at a time and ends at a failure and its trace.

Add ProtoTest to your own project​

Template (fastest)Your own project (control)
Start withdotnet new prototest -n Shopthe dotnet add package lines below
You geta working API, suite, trace and reportProtoTest inside a project you already have
Pick the other whenyou already have an application or a suiteyou want the composed example to copy from

A suite is one runner package, ProtoTest.Core, and one package per integration. Infrastructure hangs off the integration it serves:

your suite = runner (1 of 5) + Core + 1 package per integration
runner: ProtoTest.NUnit, .Xunit, .Xunit3, .MSTest, .TUnit (pick one)
integrations: Rest, GraphQL, Grpc, Data, Sql, Sheets, OpenApi, ...
infrastructure: Sql.Testcontainers or Messaging.RabbitMq.Testcontainers,
next to the Sql or Messaging integration they serve

Pick one package per integration you use, plus infrastructure and extras where you need them:

terminal
dotnet add package ProtoTest.Core # host, context, hooks, attributes, trace
dotnet add package ProtoTest.NUnit # NUnit
The runner packages are ProtoTest.NUnit, ProtoTest.Xunit (v2), ProtoTest.Xunit3, ProtoTest.MSTest and ProtoTest.TUnit. Each one needs a small setup class; see Test runners.

The NUnit adapter needs NUnit 4.6.1 or newer; the standard dotnet new nunit template pins an older version, so update it first:

dotnet add package NUnit --version 4.6.1

Preview packages​

The preview set works but its surface can change before the next minor release: Sheets, WireMock, the devices family, Aspire, the MassTransit bridge, the agent layer (Mcp, Diagnosis, Verification, Feedback, Cli) and Analyzers. Add one per need the same way:

dotnet add package ProtoTest.Sheets
dotnet add package ProtoTest.WireMock
dotnet add package ProtoTest.Aspire

What comes along​

You addYou also getAdd it directly when you
any packageProtoTest.Coreyour code names Core types: a hook, an attribute, a context extension
ProtoTest.Rest, ProtoTest.GraphQL, ProtoTest.GrpcProtoTest.Http, ProtoTest.Jsonyou build on the shared HTTP layer or shape constraints without those integrations
ProtoTest.SheetsProtoTest.Jsonyou use shape constraints outside Sheets
ProtoTest.Web.Playwright, ProtoTest.Web.SeleniumProtoTest.Webyou write a backend on the shared web layer
ProtoTest.Messaging.RabbitMqProtoTest.Messagingyou write an adapter on the messaging layer
ProtoTest.Sql.EntityFrameworkCoreProtoTest.Sqlyou use the per-test connection without EF Core
ProtoTest.Sql.Testcontainers, ProtoTest.Messaging.RabbitMq.TestcontainersProtoTest.Testcontainersyou write a container of your own
ProtoTest.OpenApiProtoTest.Restyou call the REST layer the coverage reads

ProtoTest.Http is the shared HTTP client and authentication layer behind REST, GraphQL and gRPC. Application suites reference the integration, not the layer.

Browsers for Playwright​

Set InstallBrowsers to download the browser before the first launch. A clean machine or CI runner then needs no extra install step. Which backend to pick is on Which backend.

Where to next​