Skip to content

Diagram Customisation

Aryeh Citron edited this page May 10, 2026 · 12 revisions

The TrackingDiagramOverride static class (available in every integration package) lets you manually control what appears in the generated diagrams.

TrackingDiagramOverride API

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+): DefaultTrackingDiagramOverride also accepts a Func<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");

StartOverride / EndOverride

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");

InsertPlantUml

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.

InsertTestDelimiter

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: InsertTestDelimiter is 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

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)
Example diagram with SeparateSetup enabled

The boundary between setup and action is determined by:

  1. Explicit — Call TrackingDiagramOverride.StartAction() in your test code (see StartAction below)
  2. 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)

StartAction

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.

StartSetup

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.

Field Highlighting with DiagramFocus

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.

PlantUML Themes

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:

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 !theme directive value, e.g. "amiga from https://raw.githubusercontent.com/plantuml/plantuml/master/themes".

Dependency-Type Coloring

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).

Default Palette

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

Disabling Arrow Colors

new ReportConfigurationOptions
{
    SequenceDiagramArrowColors = false  // plain arrows, no dependency coloring
}

Enabling Participant Background Colors

new ReportConfigurationOptions
{
    SequenceDiagramParticipantColors = true  // add colored backgrounds to participant boxes
}

Custom Colors per Dependency

new ReportConfigurationOptions
{
    DependencyColors = new Dictionary<string, string>
    {
        ["CosmosDB"] = "#FF0000",  // red for CosmosDB
        ["Redis"] = "#00FF00"      // green for Redis
    }
}

Overriding Service Types

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
    }
}

Home


Demo


Getting Started

Common Tasks

Integration Guides

Extensions

Configuration

Features

Reference

Clone this wiki locally