Skip to content

Project Templates

Aryeh Citron edited this page May 5, 2026 · 6 revisions

Project Templates

Added in v2.29.17

TestTrackingDiagrams ships a dotnet new template pack containing 12 pre-configured project templates for all supported test frameworks. Each template creates a fully working component test project with:

  • HTTP dependency tracking configured
  • Report generation with diagrams
  • Assertion tracking pre-configured (via AssertionRewriter)
  • A sample test/scenario demonstrating the complete workflow

Installation

dotnet new install TestTrackingDiagrams.Templates

Available Templates

Short Name Framework Description
ttd-xunit3 xUnit v3 Component tests with xUnit v3
ttd-xunit2 xUnit v2 Component tests with xUnit v2
ttd-tunit TUnit Component tests with TUnit
ttd-nunit4 NUnit 4 Component tests with NUnit 4
ttd-mstest MSTest Component tests with MSTest
ttd-lightbdd-xunit3 LightBDD + xUnit v3 BDD-style component tests with LightBDD and xUnit v3
ttd-lightbdd-xunit2 LightBDD + xUnit v2 BDD-style component tests with LightBDD and xUnit v2
ttd-lightbdd-tunit LightBDD + TUnit BDD-style component tests with LightBDD and TUnit
ttd-bddfy-xunit3 BDDfy + xUnit v3 BDD-style component tests with BDDfy and xUnit v3
ttd-reqnroll-xunit3 ReqNRoll + xUnit v3 Gherkin BDD tests with ReqNRoll and xUnit v3
ttd-reqnroll-xunit2 ReqNRoll + xUnit v2 Gherkin BDD tests with ReqNRoll and xUnit v2
ttd-reqnroll-tunit ReqNRoll + TUnit Gherkin BDD tests with ReqNRoll and TUnit

Usage

# Create an xUnit v3 test project
dotnet new ttd-xunit3 -n MyApi.Tests.Component

# Create with custom service names
dotnet new ttd-xunit3 -n MyApi.Tests.Component \
  --serviceName "OrderService" \
  --downstreamService "PaymentGateway" \
  --downstreamPort 15060

# Create a ReqNRoll project targeting .NET 9
dotnet new ttd-reqnroll-xunit3 -n MyApi.Tests.BDD --Framework net9.0

Template Parameters

All templates accept these parameters:

Parameter Default Description
--serviceName MyApi Name of the service under test (used in diagram labels and report titles)
--downstreamService DownstreamService Name of a downstream dependency (used in port-to-service mapping)
--downstreamPort 15050 Port for the downstream service
--Framework net10.0 Target framework (net8.0, net9.0, or net10.0)

What's Included

Each generated project contains:

File Purpose
*.csproj Project file with all required package references
appsettings.componenttests.json Configuration for downstream service URLs
AssertionTracking.cs [assembly: TrackAssertions] opt-in for automatic assertion rewriting
Infrastructure/BaseFixture.cs WebApplicationFactory setup with dependency tracking (xUnit/NUnit/MSTest/TUnit)
Infrastructure/TestRun.cs Report generation on test run completion
Scenarios/SampleFeature.cs Working example test demonstrating assertions + HTTP calls
Program.cs Minimal API host for the service under test

For ReqNRoll templates, the structure uses Gherkin features:

File Purpose
Features/Sample.feature Example Gherkin scenario
StepDefinitions/SampleStepDefinitions.cs Step implementations
Hooks/TestSetupHooks.cs Test lifecycle hooks with TTD tracking
reqnroll.json ReqNRoll binding configuration

After Scaffolding

  1. Add a project reference to your API project:

    <ProjectReference Include="..\YourApi\YourApi.csproj" />
  2. Update Program.cs to match your actual API startup (or remove it and reference the real Program class).

  3. Configure downstream services in appsettings.componenttests.json.

  4. Run the sample test to verify everything works:

    dotnet test
  5. Open the generated report at bin/Debug/net10.0/Reports/FeaturesReport.html.


Assertion Tracking

All templates include the TestTrackingDiagrams.AssertionRewriter package and an AssertionTracking.cs file with:

using TestTrackingDiagrams.Tracking;

[assembly: TrackAssertions]

This means every .Should() assertion in the project is automatically wrapped in Track.That() at compile time — assertions appear as inline notes in your sequence diagrams with no manual effort. See Assertion Tracking for details.


Uninstalling

dotnet new uninstall TestTrackingDiagrams.Templates

Home


Demo


Getting Started

Common Tasks

Integration Guides

Extensions

Configuration

Features

Reference

Clone this wiki locally