Labcoat.Testing.TUnit 1.2.1

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

Labcoat.Testing.TUnit

TUnit support for Labcoat: give each TUnit integration test its own OpenTelemetry trace, 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. Built on Labcoat.Testing (the framework-neutral core, brought in by this package). Requires TUnit 1.68 or later. AOT-compatible: works in Native AOT TUnit test apps.

Setup: two steps

  1. Add the package to the test project. That registers the tracing, no hooks to write: the package adds [assembly: LabcoatTracing] (a TUnit test start / end event receiver).

    dotnet add MyApp.Tests package Labcoat.Testing.TUnit
    
  2. Call LabcoatTracing.ConfigureAspireTesting(builder) in the fixture that creates the app (for TUnit, the shared class the tests start the app from), after CreateAsync and before BuildAsync. The package can't do this step for you: 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);
    

    A complete fixture: AspireSample.TUnitTests/AspireApp.cs.

Everything is a no-op unless the tests run under Labcoat hosted by an Aspire AppHost (builder.AddLabcoat(...)) with trace collection turned on (off by default: .WithTestTracing(), the Toggle test tracing dashboard command or the toggle in the Labcoat UI). Safe to leave in place for dotnet test and CI.

How it works

TUnit starts an Activity per test itself (TestContext.Activity, a new trace per test) and makes it current in the test body, so HTTP calls the test makes carry its W3C traceparent. The adapter adopts that activity: it names it after the test, tags it (test.id is the test node uid TUnit reports to Labcoat, i.e. TestDetails.TestId; test.class, test.name, test.outcome, ...), writes labcoat:traceId=<hex> to the test's output (Labcoat strips that line and links the test to /traces/detail/<traceId>) and exports the spans of that trace (TUnit's test spans under the test assembly's name). TUnit's session, assembly and class spans are not exported.

Options

  • Only some tests, by category or trait: a trace filter in the Labcoat UI's search syntax (cat:Integration, trait:Kind=Slow, name text). From the AppHost: .WithTestTracing(filter: "cat:Integration") (it wins). As this project's default:

    <LabcoatTracingFilter>cat:Integration</LabcoatTracingFilter>
    

    The adapter passes the test's [Category] and [Property] as Labcoat shows them, so cat:Integration matches a test marked [Category("Integration")] and trait:Kind=Slow one marked [Property("Kind", "Slow")]. A test that doesn't match gets no span and no trace id. See Trace only some tests.

  • Only some classes: set <LabcoatTracingAutoRegister>false</LabcoatTracingAutoRegister> in the test project and put [LabcoatTracing] (optionally with Filter = "...") on the classes or methods to trace.

  • GenerateAssemblyInfo is false, or the package is referenced through another project: the attribute is not added for you; write [assembly: LabcoatTracing] in the test project.

Live console output needs nothing extra with TUnit: Labcoat streams TUnit's own in-progress output.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.2.2 96 11/1/2026
1.2.1 120 11/1/2026
1.2.0 111 11/1/2026
1.1.2 740 10/16/2026
1.1.1 567 10/11/2026
1.1.0 211 10/11/2026
1.0.0 126 10/11/2026