What problem does it solve?
Writing and reviewing C# tests in TUnit-heavy projects can be challenging due to data source selection, lifecycle management, and complex parallelism. This skill provides guidance on best practices, patterns, and considerations to write robust tests with TUnit.
Core Features & Use Cases
- Guidance on choosing appropriate data sources (MethodDataSource, ClassDataSource, Shared fixtures) for deterministic tests.
- Advice on lifecycle hooks (Before, After, IAsyncInitializer, IAsyncDisposable) to manage test fixtures and resources.
- Recommendations for parallelism controls and avoiding common pitfalls when tests run concurrently.
- Patterns for asynchronous assertions and diagnostics to improve reliability and observability in test results.
- Real-world use cases and example scenarios from C# test suites using TUnit.
Quick Start
Apply TUnit best practices in your C# tests by following the patterns described here to structure data sources, fixtures, and asynchronous assertions.