xunit

Write, run, and repair .NET tests using xUnit v2 or v3 with correct runner configuration.

Updated May 2, 2026
One-click install
npx skills add https://github.com/hdeshev/pi-config --skill xunit-hdeshev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: xunit
Source: https://github.com/hdeshev/pi-config/tree/main/agent/skills/xunit
Command: npx skills add https://github.com/hdeshev/pi-config --skill xunit-hdeshev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? .NET teams often struggle with inconsistent xUnit setups: mixing VSTest and Microsoft.Testing.Platform flags, running the wrong CLI for xUnit v2 versus v3, or writing flaky tests with shared state and non-deterministic inputs. This Skill detects the active xUnit model in a repository and applies the correct packages, commands, and test-writing patterns. ## Core Features & Use Cases - Runner Detection: Identifies whether a project uses xUnit v2, xUnit v3, VSTest compatibility, or Microsoft.Testing.Platform by inspecting project files before running any command. - Test Authoring Guidance: Provides patterns for [Fact], [Theory], class and collection fixtures, NSubstitute and Moq mocking, and async tests, plus a catalog of anti-patterns to avoid. - Bootstrap and Repair: Adds xUnit packages to projects missing them, fixes broken test commands, and keeps CI runs consistent with the active runner model. - Use Case: A developer inherits a repo where dotnet test fails after migrating to xUnit v3. The Skill detects the v3 standalone runner, switches to dotnet run with the correct filter syntax, and repairs the failing tests. ## Quick Start Ask the agent to run or fix the xUnit tests in your .NET project and it will detect the runner model, execute the right command, and report verification results.

Frequently Asked Questions about xunit

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

FAQPage Schema
How do I run xUnit tests in a .NET project?▼

Run `dotnet test` on the solution or test project for VSTest-based setups, which covers most xUnit v2 projects. For xUnit v3 standalone projects, use `dotnet run --project` on the test project instead, since v3 can execute as its own executable.

What is the difference between xUnit v2 and xUnit v3?▼

xUnit v2 uses the `xunit` package and typically runs through VSTest with `xunit.runner.visualstudio`. xUnit v3 uses the `xunit.v3` package and can run as a standalone executable or integrate with Microsoft.Testing.Platform, changing which CLI commands and filters apply.

Should I use VSTest or Microsoft.Testing.Platform for xUnit?▼

Check the project file first: `xunit.runner.visualstudio` with `Microsoft.NET.Test.Sdk` indicates VSTest, while `TestingPlatformDotnetTestSupport` or `UseMicrosoftTestingPlatformRunner` indicates Microsoft.Testing.Platform. Keep one runner model per project and never mix VSTest-only flags with platform flags in the same command.

How do I filter xUnit tests to run a single class or method?▼

For VSTest runs, use `dotnet test --filter "FullyQualifiedName~Namespace.TypeName"`. For xUnit v3 with Microsoft.Testing.Platform, use `dotnet run --project ... -- --filter-class Namespace.TypeName`. Always match the filter syntax to the active runner.

When should I not use this xUnit Skill?▼

Do not use it for TUnit or MSTest projects, since their packages, runners, and idioms differ. It also does not auto-migrate repos from other frameworks to xUnit unless migration is explicitly requested.

Why do my xUnit tests fail intermittently?▼

Intermittent failures usually come from shared mutable state between tests, reliance on wall-clock time or randomness, or `async void` test methods that xUnit cannot await. Use per-test setup, inject time providers, and return `Task` from async tests to make them deterministic.