What problem does it solve?
This Skill helps .NET developers write more effective, maintainable, and robust unit and integration tests, reducing bugs and improving code quality.
Core Features & Use Cases
- Test Structure & Naming: Enforces clear Arrange-Act-Assert patterns and descriptive test names.
- xUnit Best Practices: Guides on using
[Fact] vs [Theory] and appropriate data attributes.
- Mocking Strategies: Recommends using NSubstitute for mocking external dependencies effectively.
- Assertion Libraries: Promotes FluentAssertions for readable and expressive assertions.
- Integration Testing: Demonstrates using
WebApplicationFactory for testing ASP.NET Core applications.
- Database Testing: Provides strategies for testing with SQLite in-memory or Testcontainers.
- Async Testing: Covers best practices for testing asynchronous code, including cancellation and timeouts.
- Test Organization: Advises on structuring test classes and using fixtures (
IClassFixture, ICollectionFixture).
- Anti-Pattern Avoidance: Highlights common pitfalls in testing and how to fix them.
Quick Start
Use the dotnet-testing skill to refactor a test method to follow the Arrange-Act-Assert pattern.