Skip to content

Guide · Agent skill

How to use the C# XUnit Testing Guide agent skill

Updated · written with AI from the project's own documentation and checked against our catalogue data

The csharp-xunit skill is a set of written best practices that an AI agent reads when you ask it to write unit tests in C# with the XUnit framework. It is aimed at C# developers on .NET projects and at teams that want their tests to follow the same conventions. After this guide you will know how to install the skill, how to phrase a request so the agent uses it, and what to check in the output.

C# XUnit Testing Guidegithub/awesome-copilot · MIT

Quick start

  1. 1Download the ZIP. Download the csharp-xunit ZIP from this page.
  2. 2Unzip into a skills folder. Unzip it into ~/.claude/skills/ for all projects, or into your project's .claude/skills/ folder for one project.
  3. 3Or upload in the Claude apps. In the Claude apps, open Settings, go to Capabilities and choose Skills to upload the ZIP.
  4. 4Check your .NET setup. Make sure the .NET SDK is installed and your test project references xunit, xunit.runner.visualstudio and Microsoft.NET.Test.Sdk.
  5. 5Ask for tests in plain language. Name C# and XUnit, describe the code and the cases you want covered.
  6. 6Run the tests. Run dotnet test in your test project and review the results.

What the skill makes the agent do

The skill is a checklist, not a program. It tells the agent how to structure XUnit tests so they look consistent across a project. When it applies, the agent is guided to keep a separate test project named [ProjectName].Tests, name test classes after the classes they test (for example CalculatorTests for Calculator), and follow the Arrange-Act-Assert pattern.

It also covers naming (MethodName_Scenario_ExpectedBehavior), single-behavior tests, [Fact] for simple cases, and [Theory] with data attributes such as [InlineData], [MemberData] and [ClassData] for data-driven tests. It lists assertion choices such as Assert.Equal, Assert.Throws<T> and Assert.Contains, and mocking guidance that suggests Moq or NSubstitute.

  • Separate test project named [ProjectName].Tests
  • Arrange-Act-Assert structure with clear test names
  • Fact tests for simple cases and Theory tests for data-driven cases
  • Focused, independent tests that can run in any order

Install the skill in Claude Code

Download the ZIP for this skill from this page and unzip it. The skill is a single file named SKILL.md inside a folder called csharp-xunit. To make it available to every project on your machine, place the folder in ~/.claude/skills/. To make it available only to one project, place it in that project's .claude/skills/ folder.

Once the folder is in place, start a new session so the agent can see it.

  • Personal (all projects): ~/.claude/skills/csharp-xunit/
  • Single project: .claude/skills/csharp-xunit/ inside your project

Install the skill in the Claude apps

If you use the Claude apps rather than Claude Code, you can upload the skill instead. Download the ZIP from this page, then open Settings, go to Capabilities and choose Skills to upload it.

Ask for tests in a way that triggers the skill

The skill is used when your request is about writing or improving C# unit tests. Name the language and the framework so the agent knows which conventions to follow. You do not need special syntax. Describe the code you want tested and what you want covered.

Mention data-driven tests if you want several inputs checked by one test method, since the skill has specific guidance for that.

  • Write XUnit tests for my Calculator class in C#, including edge cases for division by zero.
  • Add a data-driven XUnit Theory with InlineData for my ParseDate method.
  • Review my existing test project and suggest how to make the tests follow XUnit best practices.

Set up your project so the tests can run

The skill assumes you have the .NET SDK, because tests are run with the dotnet test command. The guidance also expects the XUnit packages xunit and xunit.runner.visualstudio, plus Microsoft.NET.Test.Sdk, to be referenced in the test project. The skill does not install these for you, so check they are present before you run the agent's tests.

  • Install the .NET SDK
  • Reference Microsoft.NET.Test.Sdk, xunit and xunit.runner.visualstudio in your test project
  • Run the tests with dotnet test
dotnet test

Safety notes: scripts and network

This skill is guidance only. It does not run scripts and does not use the network. It does not run anything on your machine by itself. Any commands the agent runs while writing or testing your code are run through your normal agent session, so review them as you would any other change to your project.

  • Runs scripts: no
  • Uses network: no
  • Only file included: SKILL.md

Tips for getting better results

Give the agent the class or method under test, and say which behaviours matter. The skill asks for focused tests, so one request covering many unrelated behaviours will still produce several tests. Ask the agent to check its own output against the conventions, for example naming and one-assertion-focus, and to use an existing test file as a model if your team already has one.

If your project uses MSTest or NUnit, do not use this skill. Its guidance is specific to XUnit and would push the agent in the wrong direction.

  • Name the class under test and the behaviours to cover
  • Ask the agent to follow the existing test project's style
  • Skip this skill for MSTest or NUnit projects

What people use it for

  • Writing a standard set of Fact tests for a service class in a .NET project
  • Converting repeated test methods into one data-driven Theory with InlineData
  • Setting up a new [ProjectName].Tests project with consistent naming
  • Reviewing an existing XUnit test file against Arrange-Act-Assert and naming conventions

Frequently asked questions

Is the csharp-xunit skill free?

The skill is published under the MIT licence in the github/awesome-copilot repository. The source provided for this page does not mention pricing, so check the repository for licence terms.

What do I need to use the csharp-xunit skill?

You need the .NET SDK for the dotnet test command, and a test project that references xunit, xunit.runner.visualstudio and Microsoft.NET.Test.Sdk. The skill itself is a single SKILL.md file.

Where do I put the csharp-xunit skill folder?

Put it in ~/.claude/skills/ to use it across all projects, or in a project's .claude/skills/ folder to use it for that project only. In the Claude apps you can upload the ZIP under Settings, Capabilities, Skills.

Does the skill run code or access the internet?

No. The skill runs no scripts and uses no network. It is written guidance that the agent follows when writing XUnit tests.

Can I use this skill with MSTest or NUnit?

No. The guidance is specific to XUnit, and the skill notes that MSTest and NUnit need different conventions, such as test class attributes. Use a skill or guidance for your framework instead.

Which mocking library does the skill use?

It suggests Moq or NSubstitute as options alongside XUnit. It does not choose one for you, so tell the agent which library your team uses.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you write C# tests with XUnit and want an agent to follow consistent conventions, especially for data-driven Theory tests. Skip it if your project uses MSTest or NUnit, or if you need the agent to standardise on one specific mocking library.

Download the skill