-
Notifications
You must be signed in to change notification settings - Fork 1
Diagram Customisation
The TrackingDiagramOverride static class (available in every integration package) lets you manually control what appears in the generated diagrams.
Each integration package provides a TrackingDiagramOverride class that wraps the core DefaultTrackingDiagramOverride and automatically resolves the current test ID from the framework's test context. The API is identical across all integrations:
TrackingDiagramOverride.StartOverride(plantUml?);
TrackingDiagramOverride.EndOverride(plantUml?);
TrackingDiagramOverride.InsertPlantUml(plantUml);
TrackingDiagramOverride.InsertTestDelimiter(testIdentifier);
TrackingDiagramOverride.StartSetup();
TrackingDiagramOverride.StartAction();Direct use (v2.0.131+):
DefaultTrackingDiagramOverridealso accepts aFunc<string>delegate for test ID resolution, so you can call it directly without the framework-specific wrapper:DefaultTrackingDiagramOverride.StartOverride(() => TestContext.Current.Test!.UniqueID); DefaultTrackingDiagramOverride.InsertPlantUml(() => myTestId, "note across: custom");
Suppress automatic diagram generation for a section of your test. Any HTTP calls made between StartOverride() and EndOverride() will not appear in the diagram. Optionally inject custom PlantUML at the start/end boundaries:
TrackingDiagramOverride.StartOverride("note across: Starting setup phase");
// These HTTP calls will NOT appear in the diagram
await client.PostAsync("/api/seed-data", content);
TrackingDiagramOverride.EndOverride("note across: Setup complete");Insert arbitrary PlantUML code into the diagram at the current position:
TrackingDiagramOverride.InsertPlantUml("note across: User is now authenticated");
TrackingDiagramOverride.InsertPlantUml("== Phase 2: Order Processing ==");Any valid PlantUML syntax can be injected — notes, dividers, delays, groups, etc.
Insert a visual test boundary marker in the diagram. Useful when a single test logically contains multiple phases:
TrackingDiagramOverride.InsertTestDelimiter("Verify Initial State");
// ... test code ...
TrackingDiagramOverride.InsertTestDelimiter("Verify After Update");This renders as a black horizontal note across all participants with white text showing Test {identifier}.
Tip:
InsertTestDelimiteris particularly useful when using TabularAttributes, where a single scenario runs multiple iterations. Insert a delimiter between each iteration to clearly separate them in the diagram.
Setup separation visually distinguishes the "arrange" phase of a test from the "act" phase in the generated sequence diagrams by wrapping setup HTTP calls in a PlantUML partition block.
To enable it, set SeparateSetup = true on ReportConfigurationOptions:
new ReportConfigurationOptions
{
SeparateSetup = true,
HighlightSetup = true // default — adds a background colour to the partition
}| Property | Effect |
|---|---|
SeparateSetup = false |
No partition — all calls rendered sequentially (default) |
SeparateSetup = true, HighlightSetup = true |
Setup calls wrapped in a coloured partition |
SeparateSetup = true, HighlightSetup = false |
Setup calls wrapped in a plain partition (no background colour) |
The boundary between setup and action is determined by:
-
Explicit — Call
TrackingDiagramOverride.StartAction()in your test code (see StartAction below) - Implicit (BDD frameworks) — Automatically detected when the test transitions from a GIVEN step to a WHEN or THEN step (supported in BDDfy, LightBDD, and ReqNRoll)
For non-BDD frameworks (or to override automatic detection), explicitly mark the boundary by calling TrackingDiagramOverride.StartAction():
// Setup phase — these calls appear inside the partition
await client.PostAsync("/api/seed-data", content);
await client.PostAsync("/api/configure", settings);
TrackingDiagramOverride.StartAction();
// Action phase — these calls appear after the partition
var response = await client.GetAsync("/api/cake");BDD frameworks (BDDfy, LightBDD, ReqNRoll):
StartAction()is called automatically when the test transitions from a GIVEN step to a WHEN or THEN step. You only need to call it explicitly if you want to override the automatic detection.
Explicitly mark the beginning of the setup phase. This sets the ambient TestPhaseContext.Current to Setup, enabling Phase-Aware Tracking — per-phase verbosity overrides and enable/disable toggles on all tracking extensions.
TrackingDiagramOverride.StartSetup();
// Setup phase — tracking extensions can use different verbosity or be disabled
await client.PostAsync("/api/seed-data", content);
TrackingDiagramOverride.StartAction();
// Action phase — full tracking detail
var response = await client.GetAsync("/api/cake");BDD frameworks:
StartSetup()is called automatically based on the step keyword (Given/And/But → Setup). You only need to call it explicitly in non-BDD tests.
See Phase-Aware Tracking for the full guide on configuring per-phase verbosity and enable/disable behaviour.
For controlling which JSON fields are visually emphasised or de-emphasised within diagram notes, see Content Formatting#DiagramFocus (Field Highlighting). The preferred approach is the fluent WithDiagramFocus() extension method on HttpClient, which makes the association between focus and HTTP call explicit:
var response = await client.WithDiagramFocus()
.OnRequest<CreateCakeRequest>(x => x.Flour, x => x.Eggs)
.OnResponse<CreateCakeResponse>(x => x.BatchId)
.PostAsJsonAsync("/api/cake", requestBody);Focused fields are rendered in bold (or coloured), while non-focused fields are grayed out or hidden. Configure the styling globally via the FocusEmphasis and FocusDeEmphasis properties on ReportConfigurationOptions.
You can apply a PlantUML theme to all generated diagrams by setting the PlantUmlTheme property on ReportConfigurationOptions:
new ReportConfigurationOptions
{
PlantUmlTheme = "spacelab"
}This injects a !theme spacelab directive into every generated diagram, changing colours, fonts, and styling to match the chosen theme.
Browse available themes:
- PlantUML Theme Gallery — visual gallery of all built-in themes
- PlantUML Theme Documentation — theme syntax, local themes, and remote themes
When PlantUmlTheme is null (the default), no theme directive is emitted and diagrams use PlantUML's default styling.
Tip: You can also use themes hosted on remote URLs by specifying the full
!themedirective value, e.g."amiga from https://raw.githubusercontent.com/plantuml/plantuml/master/themes".
By default, sequence diagram arrows and participants are coloured by the target service's dependency type. This is determined automatically from the DependencyCategory set by extension packages (CosmosDB, Redis, EF Core, ServiceBus, BigQuery, BlobStorage).
| Dependency Type | Colour | Hex | Shape |
|---|---|---|---|
| HTTP API | Blue | #438DD5 |
entity |
| Database | Red | #E74C3C |
database |
| Cache | Orange | #F39C12 |
collections |
| Message Queue | Purple | #9B59B6 |
queue |
| Storage | Green | #2ECC71 |
database |
| Unknown | Grey | #95A5A6 |
participant |
new ReportConfigurationOptions
{
SequenceDiagramArrowColors = false // plain arrows, no dependency coloring
}new ReportConfigurationOptions
{
SequenceDiagramParticipantColors = true // add colored backgrounds to participant boxes
}new ReportConfigurationOptions
{
DependencyColors = new Dictionary<string, string>
{
["CosmosDB"] = "#FF0000", // red for CosmosDB
["Redis"] = "#00FF00" // green for Redis
}
}If a service is being mis-classified (e.g., a caching proxy showing as HTTP instead of Cache), use ServiceTypeOverrides:
new ReportConfigurationOptions
{
ServiceTypeOverrides = new Dictionary<string, string>
{
["CachingProxy"] = "Redis" // treat CachingProxy as Cache type
}
}Getting Started
Common Tasks
Integration Guides
- Integration xUnit3
- Integration xUnit2
- Integration NUnit
- Integration MSTest
- Integration TUnit
- Integration BDDfy xUnit3
- Integration LightBDD xUnit2
- Integration LightBDD xUnit3
- Integration LightBDD TUnit
- Integration ReqNRoll xUnit2
- Integration ReqNRoll xUnit3
- Integration ReqNRoll TUnit
Extensions
- Integration AtlasDataApi Extension
- Integration BigQuery Extension
- Integration Bigtable Extension
- Integration BlobStorage Extension
- Integration CloudStorage Extension
- Integration CosmosDB Extension
- Integration Dapper Extension
- Integration DynamoDB Extension
- Integration EF Core Relational Extension
- Integration Elasticsearch Extension
- Integration EventBridge Extension
- Integration EventHubs Extension
- Integration Grpc Extension
- Integration Kafka Extension
- Integration MassTransit Extension
- Integration MongoDB Extension
- Integration MySqlConnector Extension
- Integration Npgsql Extension
- Integration Oracle Extension
- Integration PubSub Extension
- Integration Redis Extension
- Integration S3 Extension
- Integration ServiceBus Extension
- Integration SNS Extension
- Integration Spanner Extension
- Integration SqlClient Extension
- Integration Sqlite Extension
- Integration SQS Extension
- Integration StorageQueues Extension
- Integration OpenTelemetry Extension
- Integration DispatchProxy Extension
- Integration MediatR Extension
- Integration PlantUML IKVM
Configuration
- Tracking Dependencies
- Tracking Custom Dependencies
- HTTP Tracking Setup
- Report Configuration
- Diagram Customisation
- Phase-Aware Tracking
- Content Formatting
- PlantUML Server Configuration
Features
- Generated Reports
- Search Syntax
- Component Diagrams
- PlantUML Browser Rendering
- Inline SVG Rendering
- Internal Flow Tracking
- Tags and Attributes
- Excluding Requests
- Excluded Headers
- Multi-Host Test Architectures
- Event-Driven Architecture Testing
- Service Bus Tracking Patterns
- Background Thread Correlation
- Parallel-Safe Background Correlation
- Event & Message Tracking
- Assertion Tracking
- Step Tracking
- Tabular Attributes
- Large Response and Diagram Handling
- Diagnostics and Debugging
- CI Summary Integration
- CI Artifact Upload
Reference