test-driven-development

Guides .NET test-driven development using xUnit or MSTest with the RED-GREEN-REFACTOR cycle.

7|Updated Jan 11, 2026
One-click install
npx skills add https://github.com/peterblazejewicz/claude-plugins --skill test-driven-development-peterblazejewicz
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: test-driven-development
Source: https://github.com/peterblazejewicz/claude-plugins/tree/main/plugins/dotnet-skills/skills/test-driven-development
Command: npx skills add https://github.com/peterblazejewicz/claude-plugins --skill test-driven-development-peterblazejewicz

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing .NET code without tests leaves bugs undetected and makes refactoring risky. This Skill enforces a disciplined test-first workflow so every behavior change is proven by a failing test before implementation, and every bug fix includes a reproduction test. ## Core Features & Use Cases - RED/GREEN/REFACTOR workflow: Write a failing xUnit or MSTest test first, implement the minimal code to pass, then refactor with tests green. - Prove-It Pattern for bug fixes: Reproduce any reported bug with a failing test before attempting a fix, guaranteeing the fix actually works. - Test pyramid guidance: Structure suites with fast unit tests at the base, WebApplicationFactory and Testcontainers integration tests in the middle, and Playwright or Avalonia.Headless E2E tests at the top. - Version awareness: Covers xUnit v2 vs v3 packaging, VSTest vs Microsoft.Testing.Platform runners, and MSTest's MTP-native support. - Use Case: A developer fixing a bug where completing a task doesn't set CompletedAt writes a failing reproduction test first, implements the fix using an injected TimeProvider, and confirms the full suite passes with dotnet test. ## Quick Start Ask the agent to implement a new .NET feature or fix a bug using test-driven development with xUnit, starting from a failing test.

Frequently Asked Questions about test-driven-development

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

FAQPage Schema
How do I practice test-driven development in .NET with xUnit?

Write a failing xUnit test first (RED), implement the minimal code to make it pass (GREEN), then refactor while keeping tests green. Run dotnet test after every change to confirm nothing broke.

What is the difference between xUnit v2 and xUnit v3?

xUnit v3 uses the xunit.v3 package, targets net8.0+, and builds test projects as executables running on Microsoft.Testing.Platform, while v2 uses VSTest. The test-authoring API ([Fact], Assert, fixtures) is source-compatible between both.

Should I use xUnit or MSTest for .NET unit testing?

Both are first-class choices with equivalent capabilities; pick one per project and stay consistent. MSTest has shipped MTP-native support since version 3.6 via the MSTest.Sdk package, while xUnit v3 is the current recommendation for new projects on .NET 8+.

Can I use EF Core InMemory provider for integration tests?

No, the InMemory provider does not enforce relational constraints, so tests can pass against it while failing in production. Use SQLite in-memory or Testcontainers with the real database provider instead.

How do I test time-dependent logic in C# without flaky tests?

Inject .NET 8's TimeProvider instead of calling DateTimeOffset.UtcNow directly, then use FakeTimeProvider from Microsoft.Extensions.TimeProvider.Testing in tests to control the clock deterministically.

When should I use mocks versus real implementations in tests?

Prefer real implementations first, then fakes, stubs, and finally interaction mocks like Moq or NSubstitute. Reserve mocks for non-deterministic or external boundaries such as email sending, payment processing, or slow third-party APIs.