Labcoat.Testing.MSTest 1.1.0

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

Labcoat.Testing.MSTest

MSTest helpers for Labcoat: give each MSTest 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, and stream console output live while a test runs. Built on Labcoat.Testing (the framework-neutral core, brought in by this package).

Setup: two steps

  1. Add the package and the two hooks (or derive the test classes from LabcoatTracedTest instead of the hooks):

    dotnet add MyApp.Tests package Labcoat.Testing.MSTest
    
    using Labcoat.Testing;
    
    [TestClass]
    public static class LabcoatHooks
    {
        [GlobalTestInitialize] public static void Start(TestContext c) => LabcoatMSTest.StartTest(c);
        [GlobalTestCleanup]    public static void End(TestContext c)   => LabcoatMSTest.EndTest(c);
    }
    
  2. Call LabcoatTracing.ConfigureAspireTesting(builder) in the fixture that creates the app (an [AssemblyInitialize] method, or the shared class the tests start the app from), 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.

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

    A complete fixture: AspireSample.Tests/Integration/AspireAppFixture.cs.

Tracing is a no-op unless the tests run under Labcoat hosted by an Aspire AppHost (builder.AddLabcoat(...)) with trace collection turned on. It 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. Safe to leave in place for dotnet test and CI.

StartTest starts an Activity named after the test (exported to the dashboard under the test assembly's name, tagged with the test's class, method and display name) and writes labcoat:traceId=<hex> to the test output; Labcoat strips that line 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. EndTest tags the outcome (test.outcome; failed, error, timeout and aborted tests get an error status).

Trace only some tests

A trace filter in the Labcoat UI's search syntax (cat:Integration, trait:Kind=Slow, name text) limits tracing to the matching tests. From the AppHost: .WithTestTracing(filter: "cat:Integration") (it wins). As the test project's default:

[assembly: LabcoatTracing(Filter = "cat:Integration")]   // or on a test class; or <LabcoatTracingFilter> in the .csproj

The adapter reads the test's [TestCategory] (method, class, base classes, assembly), [TestProperty], [Owner], [Priority] and [Description], the traits MSTest reports to Labcoat, so cat:Integration matches [TestCategory("Integration")] and trait:Kind=Slow matches [TestProperty("Kind", "Slow")]. A test that doesn't match gets no span and no trace id. The hooks still do the tracing; the attribute only narrows it. See Trace only some tests.

Live console output

MSTest attaches console output to a test's result only when the test ends. LabcoatOutput makes lines appear in Labcoat's detail pane while the test is still running, and in the test's normal output afterwards:

LabcoatOutput.WriteLine(TestContext, "Starting the Aspire app…");
using var log = LabcoatOutput.CreateWriter(TestContext); // a TextWriter (one live line per completed line)

Under Labcoat (LABCOAT_TEST_HOST=1) each line is also written to the process's raw stdout as a labcoat:live: marker tagged with the test's class, method and display name, so Labcoat attributes it exactly, also for data rows and parallel tests. Outside Labcoat it is just Console.WriteLine. No tracing setup is needed for this.

Migrating from Labcoat.Testing 0.1 (MSTest)

The MSTest parts of Labcoat.Testing moved to this package; Labcoat.Testing is now framework neutral.

  1. Replace the package: Labcoat.Testing → Labcoat.Testing.MSTest (it brings Labcoat.Testing along).
  2. In your hooks, LabcoatTracing.StartTest(c) / LabcoatTracing.EndTest(c) become LabcoatMSTest.StartTest(c) / LabcoatMSTest.EndTest(c).

Unchanged: the namespace (using Labcoat.Testing;), LabcoatTracing.ConfigureAspireTesting, LabcoatTracing.IsEnabled and its constants, the LabcoatTracedTest base class and LabcoatOutput. The spans now also carry test.framework = mstest.

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 67 11/1/2026
1.2.1 91 11/1/2026
1.2.0 82 11/1/2026
1.1.2 148 10/16/2026
1.1.1 211 10/11/2026
1.1.0 208 10/11/2026
1.0.0 115 10/11/2026