Guidance for the TUnit testing framework in .NET, focusing on async assertions and test organization.

Install

mkdir -p .claude/skills/tunit && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/13421" && unzip -o skill.zip -d .claude/skills/tunit && rm skill.zip

Installs to .claude/skills/tunit

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Use this skill to write, review, and fix TUnit tests in .NET projects: for new test classes, assertions, data-driven tests, lifecycle hooks, debugging, migrating from xUnit/NUnit, choosing assertions, using Bogus, NSubstitute mocks, integration tests, or questions about parallelism and test ordering; prefer this skill over guessing, as TUnit's async-first API has non-obvious patterns differing from xUnit/NUnit.
414 charsno explicit “when” triggerlonger than Claude Code's old 250-char listing cap (fine on current versions)
Intermediate

Key capabilities

  • Write new TUnit test classes
  • Use async-first assertions in TUnit
  • Implement data-driven tests with Arguments, MethodDataSource, ClassDataSource
  • Utilize lifecycle hooks (Before/After) and attributes (Category, Retry, Repeat)
  • Debug common TUnit mistakes like silently skipped assertions
  • Migrate existing tests from xUnit/NUnit to TUnit

How it works

The skill provides guidance and best practices for writing, reviewing, and fixing TUnit tests, emphasizing its async-first API, assertion patterns, data-driven testing, and lifecycle hooks.

Inputs & outputs

You give it
Request to write, review, or fix TUnit tests in .NET projects
You get back
TUnit test code, explanations of TUnit patterns, or debugging guidance

When to use tunit

  • Writing TUnit test classes
  • Migrating from xUnit or NUnit
  • Creating data-driven tests
  • Debugging failing tests

About this skill

TUnit Testing Skill

TUnit is a modern .NET testing framework that is async-first, source-generated, and runs on Microsoft.Testing.Platform.


Quick-start anatomy

public class OrderHandlerTests
{
    [Test]
    [Category("Unit")]                             // categorise for filtering
    public async Task PlaceOrder_Valid_ReturnsOk()
    {
        // Arrange …
        // Act …
        // Assert — always await the assertion
        await Assert.That(result).IsNotNull();
        await Assert.That(result.Status).IsEqualTo("Confirmed");
    }
}

Key rule: every assertion line must be await-ed. Forgetting the await silently skips the assertion.


Reference files — read before writing code

TopicFile
Assertion API (equality, nulls, booleans, collections, strings, exceptions, multiple)references/assertions.md
All attributes (Test, Category, Arguments, Before/After, Retry, Repeat, NotInParallel…)references/attributes.md
Data-driven tests (Arguments, MethodDataSource, ClassDataSource)references/data-driven.md
Integration test patterns (Aspire, test infrastructure, async helpers)references/integration-patterns.md

Core rules

✅ [Test] async Task               ❌ [Fact] / [TestMethod] / [TestCase]
✅ await Assert.That(...)          ❌ Assert.Equal / FluentAssertions
✅ Per-test data creation          ❌ shared mutable state between tests

Running tests

dotnet test                                              # all projects (parallel)
dotnet test -- --maximum-parallel-tests 4               # cap parallelism
dotnet test -- --treenode-filter "/*/*/*/*[Category=Unit]" # filter by category
dotnet test --project tests/MyProject.Tests/MyProject.Tests.csproj

Common mistakes & fixes

MistakeFix
Assertion silently skippedAdd await to every Assert.That(…) call
Tests interfere with each otherCreate all test data inside each test; never share mutable fields
Polling for eventual consistencyUse condition helpers or WaitForConditionAsync patterns; never Task.Delay
Assert.Fail not reached after exceptionUse Assert.That(…).Throws<T>() pattern instead of try/catch
Missing [Before(Class)] / [After(Class)]Hooks must be public static async Task; see attributes reference
Data-driven test parameters don't compileTypes in [Arguments] must exactly match method parameter types

When not to use it

  • When using xUnit or NUnit frameworks exclusively
  • When shared mutable state between tests is desired
  • When `Task.Delay` is used for polling eventual consistency

Limitations

  • Every assertion line must be `await`-ed to prevent silent skipping.
  • All test data must be created inside each test; no shared mutable fields.
  • Polling for eventual consistency should use condition helpers, not `Task.Delay`.

How it compares

This skill focuses on the TUnit framework's async-first API and specific patterns, which differ from xUnit/NUnit, providing tailored guidance for its unique features.

Compared to similar skills

tunit side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
tunit (this skill)04moReviewIntermediate
csharp-pro94moNo flagsIntermediate
performance-benchmark34moNo flagsIntermediate
run-device-tests32moReviewAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

aspnet-sse

aalmada

Implement Server-Sent Events (SSE) in ASP.NET Core using TypedResults.ServerSentEvents, SseItem<T>, and Channel-based pub/sub — including the notification service pattern, multi-instance Redis scaling, and the SseParser client. Trigger whenever the user writes, reviews, or asks about SSE, real-time

00

etag

aalmada

Use this skill for any request involving HTTP ETags, conditional requests, or optimistic concurrency in REST APIs: implementing/explaining ETag headers, preventing lost updates, designing cache validation or conditional GET/PUT/DELETE, explaining If-Match, If-None-Match, 304 Not Modified, or 412 Pre

00

bogus

aalmada

Generate realistic fake data for .NET projects using the Bogus library. Use for test data, database seeding, randomized object creation, and prototyping. Always prefer Bogus over hand-rolled random data or hardcoded test values. Trigger for any .NET test, data seeding, or sample data scenario. Use t

00

bunit

aalmada

Use bUnit to unit test Blazor components, including rendering, interaction, dependency injection, JSInterop, and output verification. Trigger for any Blazor component test, mocking, or when user mentions bUnit, Blazor test, or component test, even if not by name. Prefer this skill over hand-rolled t

00

refit

aalmada

Use Refit to define type-safe REST clients in .NET as C# interfaces backed by HttpClient — covering interface definition (HTTP verb attributes, parameter binding, return types), DI registration with AddRefitClient, DelegatingHandler pipelines for auth/headers/logging, error handling with IApiRespons

00

blazor

aalmada

Write, review, and fix Blazor Server components in the BookStore project — covering render modes (InteractiveServer), lifecycle with IDisposable cleanup, DI via @inject/[Inject], ReactiveQuery<T> for SSE-driven data loading, MudBlazor forms/dialogs/tables, tenant-aware services, and AuthorizeView gu

00

You might also like

csharp-pro

sickn33

Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.

953

performance-benchmark

dotnet

Generate and run ad hoc performance benchmarks to validate code changes. Use this when asked to benchmark, profile, or validate the performance impact of a code change in dotnet/runtime.

328

run-device-tests

dotnet

Build and run .NET MAUI device tests locally with category filtering. Supports iOS, MacCatalyst, Android on macOS; Android, Windows on Windows. Use TestFilter to run specific test categories.

325

backend-testing

exceptionless

Backend testing with xUnit, Foundatio.Xunit, integration tests with AppWebHostFactory, FluentClient, ProxyTimeProvider for time manipulation, and test data builders. Keywords: xUnit, Fact, Theory, integration tests, AppWebHostFactory, FluentClient, ProxyTimeProvider, TimeProvider, Foundatio.Xunit, TestWithLoggingBase, test data builders

316

bunit-test-migration

FritzAndFriends

Migrate bUnit test files from deprecated beta API (1.0.0-beta-10) to bUnit 2.x stable API. Use this when working on .razor test files in BlazorWebFormsComponents.Test that contain old patterns like TestComponentBase, Fixture, or SnapshotTest.

110

deployment-e2e-testing

dotnet

Guide for writing Aspire deployment end-to-end tests. Use this when asked to create, modify, or debug deployment E2E tests that deploy to Azure.

32

Search skills

Search the agent skills registry