-
Notifications
You must be signed in to change notification settings - Fork 1
PlantUML Browser Rendering
TestTrackingDiagrams can render PlantUML sequence diagrams entirely in the browser — no remote server, no IKVM package, and no Java installation required. This uses the official PlantUML TeaVM JavaScript engine, which compiles the full PlantUML Java codebase to JavaScript via TeaVM.
Because this runs the complete PlantUML engine, all features are supported — including the Teoz layout engine (!pragma teoz true), themes, all diagram types, and advanced sequence diagram features like parallel messages (&), nested boxes, and anchored durations.
Set PlantUmlRendering = PlantUmlRendering.BrowserJs on your ReportConfigurationOptions or DiagramsFetcherOptions:
new ReportConfigurationOptions
{
PlantUmlRendering = PlantUmlRendering.BrowserJs,
// ... other options
}var fetcher = DefaultDiagramsFetcher.GetDiagramsFetcher(new DiagramsFetcherOptions
{
PlantUmlRendering = PlantUmlRendering.BrowserJs
});The default value is DiagramFormat.PlantUml, so existing configurations continue to work without changes.
- During report generation,
DefaultDiagramsFetcherruns the standard PlantUML text generation pipeline — the same pipeline used for server-side and IKVM rendering. - Instead of generating server URLs or rendering images, the raw PlantUML text is stored in the
CodeBehindproperty of eachDiagramAsCode, withImgSrcleft empty. - In the HTML report, each diagram is rendered as a
<div>element with the raw PlantUML stored in adata-plantumlattribute:<div class="plantuml-browser" id="puml-0" data-plantuml="@startuml ...">Loading diagram...</div>
- Two JavaScript files are loaded from the official PlantUML CDN:
-
viz-global.js(~1.4 MB) — the Graphviz layout engine -
plantuml.js(~6.6 MB) — the PlantUML engine compiled to JavaScript
-
- An
IntersectionObserverwatches each diagram element. When a diagram scrolls within 200px of the viewport, the observer triggerswindow.plantuml.render()to render it in-place as an inline SVG.
Diagrams are lazily rendered using IntersectionObserver, equivalent to <img loading="lazy"> for traditional image-based diagrams. This is critical for large test suites:
- Diagrams outside the viewport are not rendered until the user scrolls near them
- Each diagram renders in approximately 300ms
- With 1,500 diagrams, only the visible ones render on page load — the rest render on demand as the user scrolls
- The
rootMargin: '200px'setting pre-renders diagrams 200px before they enter the viewport, so they appear ready when scrolled into view
Without lazy rendering, 1,500 diagrams would block the browser's main thread for ~7 minutes on page load.
| Aspect |
PlantUml + Server (default) |
PlantUml + Local
|
PlantUml + BrowserJs
|
Mermaid |
|---|---|---|---|---|
| Diagram syntax | PlantUML | PlantUML | PlantUML | Mermaid |
| Rendering | Server-side (remote URL) | In-process .NET via IKVM | Client-side (browser JavaScript) | Client-side (browser JavaScript) |
| HTML embedding | <img src="..."> |
<img src="..."> |
<div data-plantuml="..."> with IntersectionObserver |
<pre class="mermaid"> |
| External dependencies | PlantUML server | IKVM NuGet package | None (JS loaded from CDN on page open) | None (mermaid.js loaded from CDN on page open) |
| Teoz support | Yes | Yes | Yes | N/A |
| Themes | Yes | Yes | Yes | N/A (Mermaid has own themes) |
| Offline/self-contained | No (needs server) | Yes with Base64 | Requires internet for CDN scripts | Requires internet for CDN scripts |
| Download cost | 0 (images are pre-rendered) | 0 (images are pre-rendered) | ~8 MB JS on first page load (cached) | ~1 MB JS on first page load (cached) |
| Lazy loading | <img loading="lazy"> |
<img loading="lazy"> |
IntersectionObserver |
Mermaid.js renders all <pre> tags on startOnLoad
|
| NuGet package needed | None | TestTrackingDiagrams.PlantUml.Ikvm |
None | None |
Use PlantUmlRendering.BrowserJs when you want:
- No server dependency — Reports work without access to a PlantUML server (public or private)
- No IKVM overhead — No 30 MB NuGet package, no in-process Java rendering during test execution
- Full PlantUML feature set — Including Teoz, themes, and all diagram types, unlike Mermaid which uses a different syntax
- Local browsing — Open the HTML report file directly in a browser and diagrams render on the spot
- Fast test execution — Diagram rendering is deferred to report viewing time, not test execution time
Consider other options when:
-
No internet at viewing time — The CDN scripts need to be fetched on first page load. Use
PlantUmlRendering.LocalwithBase64Png/Base64Svgfor fully offline reports -
You prefer Mermaid syntax — Use
DiagramFormat.Mermaidfor native GitHub/Azure DevOps rendering in Markdown -
You need pre-rendered images — Use
PlantUmlRendering.ServerorPlantUmlRendering.Localfor<img>tags that don't require JavaScript -
CI summary rendering — Use
CiSummaryPlantUmlRendering = PlantUmlRendering.NodeJsto render diagrams as inline base64 SVGs via Node.js, with no server dependency. See CI Summary Integration#nodejs-rendering
Note:
PlantUmlRenderingonly applies whenDiagramFormat = DiagramFormat.PlantUml. WhenDiagramFormat = DiagramFormat.Mermaid,PlantUmlRenderingis silently ignored — diagrams are always rendered client-side by mermaid.js.
These configuration options work with PlantUmlRendering.BrowserJs because the same PlantUML text generation pipeline is used:
-
PlantUmlTheme— Themes are embedded in the PlantUML text (!theme <name>) and applied by the browser engine -
SeparateSetup/HighlightSetup— Setup separation boxes are part of the PlantUML syntax -
FocusEmphasis/FocusDeEmphasis— Field highlighting is applied to the PlantUML text -
ExcludedHeaders— Header filtering happens during text generation - All formatting processors (
RequestPreFormattingProcessor,RequestPostFormattingProcessor, etc.)
These options are ignored when using PlantUmlRendering.BrowserJs:
| Option | Reason |
|---|---|
PlantUmlServerBaseUrl |
No server is used — rendering happens in the browser |
PlantUmlImageFormat |
The browser engine always renders SVG |
LocalDiagramRenderer |
No local rendering — diagrams are rendered in the browser |
LocalDiagramImageDirectory |
No image files are produced |
Note:
LazyLoadDiagramImagesis also not applicable in the traditional sense — lazy rendering is always enabled viaIntersectionObserverand cannot be disabled forBrowserJs.
The CI Summary Interactive HTML report (CiSummaryInteractive.html) also uses client-side PlantUML rendering with the same lazy IntersectionObserver approach. It uses the official PlantUML TeaVM JS engine from plantuml.github.io.
See CI Summary Integration for details on enabling CI summaries.
The Teoz layout engine is a newer PlantUML layout engine that supports:
-
Parallel messages — Use
&to show messages sent simultaneously - Nested boxes — Group participants in hierarchical boxes
- Anchors and durations — Label time spans between diagram events
To use Teoz, include the pragma in your PlantUML text. You can inject it globally using a formatting processor:
new ReportConfigurationOptions
{
PlantUmlRendering = PlantUmlRendering.BrowserJs,
RequestResponsePostProcessor = content => content // your post-processing
}Or use TrackingDiagramOverride.InsertPlantUml("!pragma teoz true") at the start of a test to enable it per-scenario. See Diagram Customisation#InsertPlantUml for details.
Teoz is fully supported by the browser engine because the complete PlantUML codebase is compiled to JavaScript.
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 ClickHouse 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
- Merging Parallel Reports
Reference