-
Notifications
You must be signed in to change notification settings - Fork 1
Quick Start (xUnit)
NEWDAY\N17781 edited this page Mar 23, 2026
·
10 revisions
This is the simplest integration path. For other frameworks see the Framework Integration Guides page.
dotnet add package TestTrackingDiagrams.XUnit
dotnet add package Microsoft.AspNetCore.Mvc.TestingThe test run fixture is a collection fixture that lives for the entire test run. Reports are generated in its Dispose method.
using TestTrackingDiagrams;
using TestTrackingDiagrams.XUnit;
public class TestRun : DiagrammedTestRun, IDisposable
{
public void Dispose()
{
EndRunTime = DateTime.UtcNow;
XUnitReportGenerator.CreateStandardReportsWithDiagrams(
TestContexts, StartRunTime, EndRunTime,
new ReportConfigurationOptions
{
SpecificationsTitle = "My API Specifications"
});
}
}[CollectionDefinition(DiagrammedComponentTest.DiagrammedTestCollectionName)]
public class DiagrammedTestCollection : ICollectionFixture<TestRun>;The base fixture creates a WebApplicationFactory with HTTP tracking wired in, and provides each test with its own HttpClient.
using TestTrackingDiagrams.XUnit;
public class BaseFixture : DiagrammedComponentTest
{
private static readonly WebApplicationFactory<Program> Factory;
static BaseFixture()
{
Factory = new WebApplicationFactory<Program>()
.WithWebHostBuilder(builder =>
{
builder.ConfigureServices(services =>
{
// Track HTTP calls FROM the SUT to its dependencies
services.TrackDependenciesForDiagrams(
new XUnitTestTrackingMessageHandlerOptions
{
CallingServiceName = "My API",
PortsToServiceNames =
{
{ 80, "My API" },
{ 5001, "Downstream Service" }
}
});
});
});
}
// Track HTTP calls TO the SUT from the test
protected HttpClient Client { get; } = Factory.CreateTestTrackingClient(
new XUnitTestTrackingMessageHandlerOptions
{
FixedNameForReceivingService = "My API"
});
}[Endpoint("/api/cake")]
public class CakeFeature : BaseFixture
{
[Fact, HappyPath]
public async Task Creating_a_cake_successfully()
{
var response = await Client.PostAsJsonAsync("/api/cake",
new { Milk = "whole", Eggs = "free-range", Flour = "plain" });
response.StatusCode.Should().Be(HttpStatusCode.OK);
}
}dotnet testAfter the tests complete, open the three generated files in bin\Debug\net8.0\Reports\:
| File | Description |
|---|---|
ComponentSpecifications.yml |
YAML specification document |
ComponentSpecificationsWithExamples.html |
HTML specification with embedded diagrams |
FeaturesReport.html |
HTML test run report with diagrams and execution summary |
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