# dotnet-xunit

A skill for writing xUnit v3 tests in .NET: attributes, fixtures, parallel runs, IAsyncLifetime.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 613 installs · ★ 86
- Author: wshaddix
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/wshaddix/dotnet-skills/tree/HEAD/skills/dotnet-xunit/SKILL.md
- Updated: 2026-02-27
- HTML: https://affpapa.org/en/nevibecode/skills/dotnet-xunit

## What it does

The skill covers how to write xUnit v3 tests: `[Fact]` and `[Theory]` attributes, `IClassFixture` and `ICollectionFixture` fixtures, parallel execution settings, `IAsyncLifetime` for async setup and teardown, custom assertions and xUnit analyzers. A comparison table lays out what changed from v2: the `xunit.v3` package replaces `xunit`, `IAsyncLifetime` now returns `ValueTask`, `[ClassData]` takes strongly typed `TheoryDataRow<T>` rows, and the optional message string on Assert methods is gone.

It targets .NET 8.0 and up. Your test project has to exist already with xUnit packages referenced — scaffolding belongs to `dotnet-add-testing`. Moving a project off xUnit v2 hits three spots: the `IAsyncLifetime` return type, the `[ClassData]` row format, and the removed Assert messages. Worth checking before you migrate.

Testing strategy and integration tests with `WebApplicationFactory` or Testcontainers are out of scope; separate skills handle those.

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-xunit -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/dotnet-xunit/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/dotnet-xunit/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-xunit -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/dotnet-xunit/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-xunit -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/dotnet-xunit/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install wshaddix/dotnet-skills dotnet-xunit
```

2. **Manually: put the files in place**
- File: `.github/skills/dotnet-xunit/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-xunit -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/wshaddix/dotnet-skills --path skills/dotnet-xunit
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/dotnet-xunit/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add wshaddix/dotnet-skills --skill dotnet-xunit -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/wshaddix/dotnet-skills/tree/HEAD/skills/dotnet-xunit/SKILL.md

## When to use it
- write a parameterized test with `[Theory]` and `[InlineData]`
- share a database connection across tests via `IClassFixture`
- switch `IAsyncLifetime` from `Task` to `ValueTask` during a v3 migration
- configure parallel test execution per collection
- replace an Assert message string with a custom assertion

## Example prompts
- Write xUnit v3 tests for DiscountCalculator: a `[Fact]` for the exception case and a `[Theory]` with `[InlineData]`
- Show me how to put the database connection in an `IClassFixture` with `IAsyncLifetime`
- What changes in my tests when I move from xUnit v2 to `xunit.v3`?

## Similar
- [migrate-xunit-to-xunit-v3](https://affpapa.org/en/nevibecode/skills/migrate-xunit-to-xunit-v3.md) — skill · 3200 installs
- [migrate-xunit-to-mstest](https://affpapa.org/en/nevibecode/skills/migrate-xunit-to-mstest.md) — skill · 2900 installs
- [csharp-xunit](https://affpapa.org/en/nevibecode/skills/csharp-xunit.md) — skill · 10328 installs
- [csharp-testing](https://affpapa.org/en/nevibecode/skills/csharp-testing.md) — skill · 4500 installs
- [dotnet-slopwatch](https://affpapa.org/en/nevibecode/skills/dotnet-slopwatch.md) — skill · 552 installs
- [csharp-developer](https://affpapa.org/en/nevibecode/agents/csharp-developer.md) — subagent · 276 installs

From the same set: [wshaddix/dotnet-skills](https://affpapa.org/en/nevibecode/by/wshaddix/dotnet-skills.md) — 5 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
