Verify.Diagnostics
April 9, 2026 ยท View on GitHub
Extends Verify to allow verification of System.Diagnostics.Activity
See Milestones for release notes.
Sponsors
Entity Framework Extensions
Entity Framework Extensions is a major sponsor and is proud to contribute to the development this project.
Developed using JetBrains IDEs
NuGet
Usage
[ModuleInitializer]
public static void Initialize() =>
VerifyDiagnostics.Initialize();
RecordingActivityListener allows, when a method is being tested, for any Activity created as part of that method call to be recorded and verified.
Call RecordingActivityListener.Start() to begin listening. All activities from any ActivitySource will be captured by default.
[Fact]
public Task Usage()
{
Recording.Start();
using var source = new ActivitySource("TestSource");
using (var activity = source.StartActivity("MyOperation"))
{
activity!.SetTag("key1", "value1");
activity.SetTag("key2", 42);
}
return Verify("result");
}
Results in:
{
target: result,
activity: {
MyOperation: {
Tags: {
key1: value1,
key2: 42
}
}
}
}
Serialization
Activities are serialized with the following conventions:
OperationNameis used as the JSON property keyDisplayNameonly included if different fromOperationNameKindonly included if notInternalStatusandStatusDescriptiononly included if notUnsetTags,Events,Links, andBaggageincluded when present- Non-deterministic values (
Id,TraceId,SpanId,ParentSpanId,Duration,StartTimeUtc,Source) are omitted
Icon
Diagnostic from The Noun Project.

