Dotnet tunit

From managedcode/PrompterOne · View interactive version

Dotnet tunit is an AI agent skill from the GitHub repository managedcode/PrompterOne. Write, run, or repair .NET tests that use TUnit. Use when a repo uses `TUnit`, `TUnit.Playwright`, `[Test]`, `[Arguments]`, `ClassDataSource`, `SharedType.PerTestSession`, or Microsoft.Testing.Platform-based execution.

How to use this skill

Skill file

TUnit

Trigger On

Value

Do Not Use For

Inputs

Quick Start

  1. Read the nearest AGENTS.md and confirm scope and constraints.
  2. Run this skill's Workflow through the Ralph Loop until outcomes are acceptable.
  3. Return the Required Result Format with concrete artifacts and verification evidence.

Workflow

  1. Confirm the project really uses TUnit and not a different MTP-based framework.
  2. Read the repo's real test command from AGENTS.md. If the repo has no explicit command yet, start with dotnet test PROJECT_OR_SOLUTION.
  3. Keep the TUnit execution model intact:
  1. Choose the fixture level deliberately:
  1. Reuse expensive fixtures with ClassDataSource<Fixture>(Shared = SharedType.PerTestSession) instead of booting distributed infrastructure per test.
  2. Fix isolation bugs instead of globally serializing the suite unless the repo already documented a justified exception.
  3. Run the narrowest useful scope first with dotnet test ... -- --treenode-filter "...". Keep TUnit arguments after --.
  4. Capture useful failure evidence: host log dumps, focused console output, coverage files, and Playwright screenshots/HTML for UI tests.
  5. Use [Test], [Arguments], hooks, and dependencies only when they make the scenario clearer, not because the framework allows it.

Bootstrap When Missing

If TUnit is requested but not configured yet:

  1. Detect current state:
  1. Add the minimal package set to the test project:
  1. Keep the runner model explicit in AGENTS.md and CI:
  1. Add one small executable test using [Test].
  2. Run dotnet test TEST_PROJECT.csproj and return status: configured or status: improved.
  3. If the repo intentionally standardizes on xUnit or MSTest, return status: not_applicable unless migration is explicitly requested.

Deliver

Validate

Test Harness

flowchart LR
  A["TUnit task"] --> B{"What does the test need?"}
  B -->|"Single component only"| C["Plain TUnit test"]
  B -->|"HTTP / SignalR / resource graph"| D["Shared Aspire/AppHost fixture"]
  B -->|"Host DI / grains / runtime services"| E["Shared Aspire/AppHost fixture + WebApplicationFactory"]
  B -->|"Browser automation"| F["Shared Aspire/AppHost fixture + Playwright"]
  C & D & E & F --> G["Run focused with --treenode-filter"]
  G --> H["Capture logs, artifacts, and coverage"]

Ralph Loop

Use the Ralph Loop for every task, including docs, architecture, testing, and tooling work.

  1. Plan first (mandatory):
  1. Execute one planned step and produce a concrete delta.
  2. Review the result and capture findings with actionable next fixes.
  3. Apply fixes in small batches and rerun the relevant checks or review steps.
  4. Update the plan after each iteration.
  5. Repeat until outcomes are acceptable or only explicit exceptions remain.
  6. If a dependency is missing, bootstrap it or return status: not_applicable with explicit reason and fallback path.

Required Result Format

For setup-only requests with no execution, return status: configured and exact next commands.

Load References

Running Tests

TUnit uses Microsoft.Testing.Platform. Use --treenode-filter for filtering (not --filter), and keep runner switches after --.

# Run all tests
dotnet test MySolution.sln

# Run one test project
dotnet test tests/MyProject.Tests/MyProject.Tests.csproj

# Filter by class
dotnet test tests/MyProject.Tests/MyProject.Tests.csproj -- --treenode-filter "/*/*/CalculatorTests/*"

# Filter by category
dotnet test tests/MyProject.Tests/MyProject.Tests.csproj -- --treenode-filter "/*/*/*/*[Category=Integration]"

# Coverage on Microsoft.Testing.Platform
dotnet test MySolution.sln -- --coverage --coverage-output coverage.cobertura.xml --coverage-output-format cobertura

# Raw runner help when the repo needs direct TUnit app switches
dotnet run --project tests/MyProject.Tests/MyProject.Tests.csproj -- --help

Filter syntax: /<Assembly>/<Namespace>/<Class>/<Test> with * wildcards. See references/patterns.md for full examples.

Example Requests

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.