Labcoat.Testing 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Labcoat.Testing --version 1.0.0
                    
NuGet\Install-Package Labcoat.Testing -Version 1.0.0
                    
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="Labcoat.Testing" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Labcoat.Testing" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Labcoat.Testing" />
                    
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 Labcoat.Testing --version 1.0.0
                    
#r "nuget: Labcoat.Testing, 1.0.0"
                    
#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 Labcoat.Testing@1.0.0
                    
#: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=Labcoat.Testing&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Labcoat.Testing&version=1.0.0
                    
Install as a Cake Tool

Labcoat.Testing

The framework-neutral core of Labcoat's test-side helpers: per-test OpenTelemetry traces for Aspire integration tests, so Labcoat can show a View trace / Structured logs link that jumps straight to what the services did during that test in the Aspire dashboard.

Setup: two steps

  1. Add the adapter package for your test framework (it brings this one; you normally don't reference this package yourself):

    Test framework Package Setup
    MSTest Labcoat.Testing.MSTest Two hooks (LabcoatMSTest.StartTest / EndTest) or a base class. Also live console output (LabcoatOutput).
    TUnit Labcoat.Testing.TUnit None: the package registers itself.
    NUnit Labcoat.Testing.NUnit None: the package registers itself. Also live console output (LabcoatOutput).
    xUnit v3 Labcoat.Testing.XUnit None: the package registers itself.
    Other this package Call the API below from your own hooks.
  2. Call LabcoatTracing.ConfigureAspireTesting(builder) in the fixture that creates the app, in every framework (also with the adapters that need no code), after CreateAsync and before BuildAsync. Without it the services the tests start send their telemetry to the testing default (localhost:4317, usually nothing), and the dashboard shows the test's span but none of the services' spans or logs.

    using Labcoat.Testing;
    
    var builder = await DistributedApplicationTestingBuilder.CreateAsync<Projects.MyAppHost>(ct);
    LabcoatTracing.ConfigureAspireTesting(builder);
    var app = await builder.BuildAsync(ct);
    

Everything is a no-op unless the tests run under Labcoat hosted by an Aspire AppHost (builder.AddLabcoat(...)) with trace collection turned on. Tracing is opt-in and off by default: enable it with .WithTestTracing() on the Labcoat resource, the Toggle test tracing dashboard command or the toggle in the Labcoat UI.

How it works

While tracing is on, Labcoat passes the dashboard's OTLP endpoint (and API key) to the test host as LABCOAT_OTLP_ENDPOINT, LABCOAT_OTLP_PROTOCOL and LABCOAT_OTLP_HEADERS. For each test the adapter calls LabcoatTracing.BeginTest: the test gets a span that is the root of its own trace (exported under the test assembly's name), and labcoat:traceId=<hex> is written to the test's own output. Labcoat strips that line from the result and links the test to /traces/detail/<traceId>. HTTP calls made during the test carry the W3C traceparent header, so the service spans join the test's trace. ConfigureAspireTesting sets ASPIRE_DASHBOARD_OTLP_ENDPOINT_URL (or ..._HTTP_ENDPOINT_URL) and AppHost:OtlpApiKey on the testing builder.

API for adapters (and for your own hooks)

// When the test starts, in the test's execution context (the span becomes Activity.Current):
var span = LabcoatTracing.BeginTest(
    new LabcoatTest("PlacesOrder(2)") { Id = uid, ClassName = "Shop.Tests.OrderTests", MethodName = "PlacesOrder", Framework = "nunit" },
    writeOutput: line => Console.WriteLine(line),   // to the test's own (captured) output
    frameworkActivity: null);                       // or the framework's own per-test root Activity, to adopt it

// When it ends:
LabcoatTracing.EndTest(span, LabcoatTestOutcome.Failed, frameworkOutcome: "Failed");
  • LabcoatTest.Id is the Microsoft.Testing.Platform test node uid (the id of the test's row in Labcoat) when the framework exposes it; it becomes the test.id span tag. The link from a test to its trace does not depend on it: the trace id travels in the test's own output.
  • frameworkActivity: frameworks that start an Activity per test themselves and make it current in the test body (TUnit) pass it here. Labcoat then tags and renames it instead of starting a span the test body would not see, and LabcoatTracing.Initialize("<framework source>") (called before the first test) makes the exporter listen to that source. Only spans of test traces are exported from it, not the framework's session or class spans.
  • LabcoatLiveOutput.Send(test, text) sends a line live to Labcoat's detail pane while the test runs (a labcoat:live: marker on the raw stdout; nothing outside Labcoat).

The design, the hook each adapter uses and how to add one for another framework are in ARCHITECTURE.md.

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 was computed.  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 was computed.  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 (4)

Showing the top 4 NuGet packages that depend on Labcoat.Testing:

Package Downloads
Labcoat.Testing.TUnit

TUnit adapter for Labcoat.Testing: per-test OpenTelemetry traces for TUnit + Aspire.Hosting.Testing integration tests, so Labcoat can link each test to its trace and logs in the Aspire dashboard. Registers itself: no code needed.

Labcoat.Testing.MSTest

MSTest adapter for Labcoat.Testing: per-test OpenTelemetry traces for MSTest + Aspire.Hosting.Testing integration tests (Labcoat links each test to its trace and logs in the Aspire dashboard), and live console output in Labcoat while a test runs.

Labcoat.Testing.NUnit

NUnit adapter for Labcoat.Testing: per-test OpenTelemetry traces for NUnit + Aspire.Hosting.Testing integration tests on Microsoft.Testing.Platform (Labcoat links each test to its trace and logs in the Aspire dashboard), and live console output in Labcoat while a test runs. Registers itself: no code needed.

Labcoat.Testing.XUnit

xUnit v3 adapter for Labcoat.Testing: per-test OpenTelemetry traces for xUnit v3 + Aspire.Hosting.Testing integration tests on Microsoft.Testing.Platform, so Labcoat can link each test to its trace and logs in the Aspire dashboard. Registers itself: no code needed.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.2 116 11/1/2026
1.2.1 148 11/1/2026
1.2.0 157 11/1/2026
1.1.2 836 10/16/2026
1.1.1 629 10/11/2026
1.1.0 293 10/11/2026
1.0.0 187 10/11/2026