TracingAssertions 0.2.0
Prefix Reserveddotnet add package TracingAssertions --version 0.2.0
NuGet\Install-Package TracingAssertions -Version 0.2.0
<PackageReference Include="TracingAssertions" Version="0.2.0" />
<PackageVersion Include="TracingAssertions" Version="0.2.0" />
<PackageReference Include="TracingAssertions" />
paket add TracingAssertions --version 0.2.0
#r "nuget: TracingAssertions, 0.2.0"
#:package TracingAssertions@0.2.0
#addin nuget:?package=TracingAssertions&version=0.2.0
#tool nuget:?package=TracingAssertions&version=0.2.0
TracingAssertions
Scope: Test projects only. Not intended for production code.
Framework-agnostic core for the TracingAssertions package family. The TUnit-native fluent assertion entry points ship in the adapter package TracingAssertions.TUnit.
Most users want
TracingAssertions.TUnit, not this package directly. Install this core directly only when authoring a non-TUnit adapter or when you only need the span-capture primitive.
What's in this package
SpanCapture: a disposable, per-test capture that starts a rawActivityListener(samplingAllDataAndRecorded) over one or moreActivitySources matched by name and collects the stoppedSystem.Diagnostics.Activityspans.ForSource(name)/ForSources(names)create one (with overloads taking anActivitySamplingResultsince v0.2.0 to capture under a chosen sampling level),Capturedexposes the collected spans in completion order, andDispose()detaches the listener. Use it with ausingstatement for per-test isolation.- Query helpers on the capture:
FindByOperationName(name),FindByOperationNameAndTag(name, tagKey, tagValue)(tag compared by invariantToString), andChildrenOf(parent)(direct children in the same trace).
No OpenTelemetry SDK, no exporter pipeline, and no NuGet runtime dependency (System.Diagnostics.DiagnosticSource is in the shared framework). AOT-compatible, trimmable, no runtime reflection.
Install
dotnet add package TracingAssertions.TUnit
The core (TracingAssertions) comes transitively; install it directly only when authoring a non-TUnit adapter for the assertion family.
License
MIT throughout. 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
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on TracingAssertions:
| Package | Downloads |
|---|---|
|
TracingAssertions.TUnit
TUnit-native OpenTelemetry distributed-tracing (Activity / span) assertions for .NET tests: fluent Assert.That(activity) entry points for operation name, tag existence and value, status, and single-hop parent/child and same-trace relationships. Span capture is a raw ActivityListener over an ActivitySource. Builds on the TracingAssertions framework-agnostic core. AOT-compatible, trimmable, no runtime reflection in the assertion path, and no NuGet runtime dependency. |
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.2.0
Minor release. Adds span and capture assertions for ASP.NET Core span testing, plus a sampling-control capture overload. Purely additive.
### Added
- **Span assertions:** `Assert.That(span).HasKind(ActivityKind)` (for example `Server` for an inbound request span), `IsRoot()` (no parent), `HasEvent(name)`, and `HasExceptionEvent()` (the OpenTelemetry `"exception"` event). The event assertions list the span's event names on failure.
- **Capture assertions:** `Assert.That(capture).HasNoSpan(operationName)` (the inverse of `HasSpan`, for asserting an operation was never traced) and `HasSpanCount(int)`.
- **`SpanCapture.ForSource(name, ActivitySamplingResult)`** and **`ForSources(ActivitySamplingResult, params string[])`** capture under a chosen sampling result. The existing parameterless forms still force `AllDataAndRecorded`. A lower result (for example `PropagationData`) lets a test exercise code that branches on `Activity.IsAllDataRequested`, with the documented caveat that an activity's effective sampling is the maximum across all active listeners, so this takes effect only when the capture is the sole listener.
### Changed
- Bumped `PackageValidationBaselineVersion` from `0.1.0` to `0.1.2` on both packages so ApiCompat strict-mode validates `0.2.0` against the most recently published baseline.