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.
Installation
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
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.
TUnit Testing Skill
TUnit is a modern .NET testing framework that is async-first, source-generated,
and runs on Microsoft.Testing.Platform.
✅ [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
Mistake
Fix
Assertion silently skipped
Add await to every Assert.That(…) call
Tests interfere with each other
Create all test data inside each test; never share mutable fields
Polling for eventual consistency
Use condition helpers or WaitForConditionAsync patterns; never Task.Delay
Assert.Fail not reached after exception
Use 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 compile
Types in [Arguments] must exactly match method parameter types