TracingAssertions.TUnit
0.1.2
Prefix Reserved
dotnet add package TracingAssertions.TUnit --version 0.1.2
NuGet\Install-Package TracingAssertions.TUnit -Version 0.1.2
<PackageReference Include="TracingAssertions.TUnit" Version="0.1.2" />
<PackageVersion Include="TracingAssertions.TUnit" Version="0.1.2" />
<PackageReference Include="TracingAssertions.TUnit" />
paket add TracingAssertions.TUnit --version 0.1.2
#r "nuget: TracingAssertions.TUnit, 0.1.2"
#:package TracingAssertions.TUnit@0.1.2
#addin nuget:?package=TracingAssertions.TUnit&version=0.1.2
#tool nuget:?package=TracingAssertions.TUnit&version=0.1.2
TracingAssertions.TUnit
Scope: Test projects only. Not intended for production code.
TUnit-native OpenTelemetry distributed-tracing (Activity / span) assertions for .NET tests. Fluent entry points over TUnit's Assert.That(...) pipeline for asserting on captured spans. AOT-compatible, trimmable, no runtime reflection in the assertion path.
What ships
Span assertions on Assert.That(span) where span is a System.Diagnostics.Activity:
| Entry point | Behavior |
|---|---|
HasOperationName(name) |
Asserts the span's OperationName equals name (ordinal). |
HasTag(key) |
Asserts a tag key is present (non-null value). |
HasTagValue(key, value) |
Asserts the tag key matches value (compared by invariant ToString). |
HasStatus(status) |
Asserts the span's Status equals the given ActivityStatusCode. |
IsChildOf(parent) |
Asserts a single-hop parent/child relationship in the same trace. |
SharesTraceWith(other) |
Asserts two spans share a TraceId. |
HasSpan(operationName) (on SpanCapture) |
Asserts the capture contains a span with that operation name. |
The framework-agnostic core (TracingAssertions) ships SpanCapture for collecting spans from one or more ActivitySources via a raw ActivityListener (no OpenTelemetry SDK or NuGet runtime dependency), plus the query helpers FindByOperationName, FindByOperationNameAndTag, and ChildrenOf.
Install
dotnet add package TracingAssertions.TUnit
Requirements: TUnit 1.50.0 or later, .NET 10. The framework-agnostic TracingAssertions core comes transitively.
Quick start
using System.Diagnostics;
using TracingAssertions;
using var capture = SpanCapture.ForSource("MyCompany.MyService");
using (var span = MyActivitySource.StartActivity("order.created"))
{
await Assert.That(span).HasOperationName("order.created");
}
The full reference is in the GitHub README.
License
MIT. No runtime dependencies beyond the BCL.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- TracingAssertions (>= 0.1.2)
- TUnit.Assertions (>= 1.48.6)
- TUnit.Core (>= 1.48.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
View the rendered release notes: https://github.com/JohnVerheij/TracingAssertions.TUnit/releases/tag/v0.1.2
Metadata-only release. No API or behavior change.
### Fixed
- Corrected the NuGet package `<Description>`. It described a foundation release carrying only `HasOperationName` and said the full fluent surface "lands in 0.1.0"; the package has shipped the complete surface (operation name, tag existence and value, status, parent/child, same-trace) since 0.1.0. The description now matches the README.
### Added
- README: a short example showing `.Because(reason)` chained on a span assertion, plus a test covering it. `.Because` is inherited from TUnit's base assertion type and has always worked on the generated span assertions; the note makes that explicit.
### Changed
- The release workflow now publishes the matching `CHANGELOG.md` section as the GitHub release body (`body_path`), so release notes carry the full hand-written detail instead of GitHub's auto-generated commit summary.