csharp-tunit

Apply TUnit conventions for test structure, data-driven tests, and lifecycle hooks.

1|Updated Mar 27, 2026
One-click install
npx skills add https://github.com/leonanpereirapinto/ai-utils --skill csharp-tunit-leonanpereirapinto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: csharp-tunit
Source: https://github.com/leonanpereirapinto/ai-utils/tree/main/skills/dotnet/csharp-tunit
Command: npx skills add https://github.com/leonanpereirapinto/ai-utils --skill csharp-tunit-leonanpereirapinto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This set of guidelines helps .NET developers write robust and maintainable unit tests using TUnit by outlining conventions for test structure, data-driven testing, and fluent assertions.

Core Features & Use Cases

  • Standard tests follow the Arrange-Act-Assert pattern with clear naming and the [Test] attribute (no xUnit/NUnit attributes needed).
  • Data-driven testing is supported through [Arguments], [MethodData], and [ClassData], enabling varied inputs without duplicating code.
  • Lifecycle hooks and advanced features (Before/After, Repeat, Retry, Parallel limits) support reliable, scalable test suites across projects.

Quick Start

Create a new test project and apply these conventions to validate a Calculator class using TUnit.

Frequently Asked Questions about csharp-tunit

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write data-driven unit tests in .NET using TUnit?

Data-driven unit testing in TUnit uses the [Arguments], [MethodData], and [ClassData] attributes to supply varied inputs without duplicating test code. You define the data source on your test method, enabling comprehensive parameterized test coverage across your .NET project.

What is the correct way to perform assertions in TUnit?

Assertions in TUnit must be performed asynchronously using the await Assert.That syntax. This fluent assertion pattern ensures your test validations execute correctly within the asynchronous test execution lifecycle of your .NET project.

Can I use xUnit or NUnit attributes for TUnit unit testing?

No, TUnit unit testing requires its own [Test] attribute instead of xUnit or NUnit attributes. Standard tests follow the Arrange-Act-Assert pattern with clear naming conventions, leveraging TUnit's specific lifecycle attributes for reliable test execution.

How do TUnit lifecycle hooks work across test classes and assemblies?

TUnit lifecycle hooks operate across classes, assemblies, and test sessions using Before and After attributes. These hooks support advanced features like Repeat, Retry, and parallel limits, enabling scalable and reliable test suite management.

What's the best way to structure a TUnit test project in .NET?

The best way to structure a TUnit test project is following the Arrange-Act-Assert pattern with clear naming conventions. Apply the [Test] attribute to methods, utilize data sources for inputs, and align with TUnit lifecycle attributes for maintainable test suites.