.NET Testing Skill
Purpose
Guide the implementation and review of automated tests in .NET applications using:
- xUnit
- Shouldly
- Testcontainers
- NSubstitute
- Bogus
- AAA pattern: Arrange, Act, Assert
- use code coverage reports to identify untested code paths and ensure critical logic is covered
The goal is to produce tests that are readable, deterministic, maintainable, and focused on behavior.
When to use
Use this skill when the task involves:
- unit tests
- integration tests
- test review or refactoring
- test naming
- use Bogus for realistic test data generation
- assertions with Shouldly
- mocks/stubs with NSubstitute
- disposable infrastructure with Testcontainers
- API, database, repository, handler, service, worker, or consumer tests
Core principles
Always prefer:
- behavior-focused tests
- clear test names
- deterministic tests
- minimal mocking
- AAA structure
- expressive assertions with Shouldly
- realistic integration tests
- isolated unit tests
- Write Unit Tests For Logic
- Avoid Over-Mocking
Avoid:
- testing private methods directly
- testing implementation details
- excessive mocks
- fragile shared state
- random data that makes failures hard to reproduce
- tests without meaningful assertions
- multiple unrelated behaviors in one test
Test naming
Prefer:
MethodName_WhenCondition_ShouldExpectedResult()