ProtoTest.Core 1.0.1

dotnet add package ProtoTest.Core --version 1.0.1
                    
NuGet\Install-Package ProtoTest.Core -Version 1.0.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ProtoTest.Core" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ProtoTest.Core" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ProtoTest.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ProtoTest.Core --version 1.0.1
                    
#r "nuget: ProtoTest.Core, 1.0.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ProtoTest.Core@1.0.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ProtoTest.Core&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ProtoTest.Core&version=1.0.1
                    
Install as a Cake Tool

ProtoTest.Core

The shared, runner-independent runtime at the centre of the ProtoTest foundation: host and lifecycle, an isolated execution context per test, hooks and attributes, clients, owned resources and tracing.

dotnet add package ProtoTest.Core

Most test projects install a runner adapter such as ProtoTest.NUnit or ProtoTest.Xunit3, which brings Core in transitively.

Quick start

public sealed class EnvironmentContext(Uri baseUri) : IProtoContext
{
    public Uri BaseUri { get; } = baseUri;
}

public sealed class EnvironmentHook : IProtoTestHook
{
    public Task BeforeTestAsync(ProtoExecutionContext context)
    {
        context.SetContext(new EnvironmentContext(new Uri("https://localhost:5099")));
        return Task.CompletedTask;
    }

    public Task AfterTestAsync(ProtoExecutionContext context) => Task.CompletedTask;
}

await using var host = new ProtoHostBuilder()
    .AddTestHook<EnvironmentHook>()
    .ConfigureTracing(trace => trace.OutputPath = "TestResults/run.prototrace")
    .AddRunGate("no error findings", context => context
        .ItemsOfKind(ProtoReportItemKinds.Finding)
        .Any(item => item.Status == ProtoReportStatus.Error)
        ? ProtoRunGateResult.Failed("The run recorded error findings.")
        : ProtoRunGateResult.Passed("No error findings were recorded."))
    .Build();

var testMethod = typeof(EnvironmentTests).GetMethod(nameof(EnvironmentTests.ReadsTheEnvironment))!;

await host.StartAsync();
_ = await host.StartTestAsync("Reads the environment", testMethod);

// Inside a test, Proto.Context is the active ProtoExecutionContext.
var environment = Proto.Context.Resolve<EnvironmentContext>();
Proto.Context.AddAttachment("environment.txt", environment.BaseUri.ToString());

What it adds

  • Host builderConfigureServices, ConfigureAppConfiguration, ConfigureTestIds, ConfigureTracing, AddTestHook<THook>, AddRunHook<TRunHook>, AddRunGate, AddResource and Build().
  • Execution contextProto.Context exposes the test identity, Resolve<T>/SetContext<T>, Client<T>(name), RegisterResource, AddAttachment, AddFinding, RecordObservation and Trace.
  • ApplicationsAddApplication(name, app => …) declares an application and its clients; AddCapability and ProtoHost.HasCapability back [RequiresCapability].
  • Skip conditions[RequiresCapability(kind, CapabilityName = …)] and [RequiresInProcess]; adapters evaluate them before StartTestAsync.
  • Tracing — the lifecycle writes test.setup, test.execution and test.teardown; entities, resources, findings and gates are recorded automatically. ProtoTraceOptions controls Enabled, OutputPath, ActivitySources, CaptureSourceLocations and EmbedSources.

One ProtoExecutionContext exists per async flow, one host per builder, and AddTestHook/AddRunHook/AddRunGate do not dedupe repeated calls.

Learn more

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (23)

Showing the top 5 NuGet packages that depend on ProtoTest.Core:

Package Downloads
ProtoTest.Json

Shared JSON shape matching and value constraints for ProtoTest integrations.

ProtoTest.Http

Shared HTTP foundations for ProtoTest protocol integrations.

ProtoTest.Web

Backend-neutral, component-based web testing for ProtoTest.

ProtoTest.Sql

A per-test database connection with transaction isolation and owned release for ProtoTest.

ProtoTest.Messaging

Messaging integration for ProtoTest: publish and await messages with a predicate and timeout over a broker capability.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.1 155 9/20/2026
1.0.0 181 9/19/2026