# Unit Testing

> Create unit tests, write tests, add tests, generate test cases for C# .NET code. Creates xUnit test project if one doesn't exist. Use for testing methods, classes, or adding test coverage.

- Skill: `danielwarddev/unit-testing` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add danielwarddev/unit-testing`
- Raw SKILL.md: https://api.skillmd.com/api/skills/danielwarddev/unit-testing/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: danielwarddev (https://skillmd.com/u/danielwarddev)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/danielwarddev/unit-testing

---


# Create Test Project

This skill writes unit tests for C# code. Beforehand, if the target .NET project doesn't have a corresponding xUnit test project yet, it first creates one and sets it up with standard packages.

## When to Use

-   User asks to "write tests" for code in a project with no corresponding test project
-   User asks to "add tests" and `{ProjectName}.UnitTests` (or similar name) doesn't exist
-   User asks to "create a test project"
-   If a similarly-named project is found, verify that the user still wants to create a new test project first.

## Process

1. Identify the project that needs tests (e.g., `MyApp.Api`)
2. Check if `{ProjectName}.UnitTests` exists (e.g., `MyApp.Api.UnitTests`)
3. If not, run `create-test-project.ps1` to scaffold the test project, placing it under the same solution as the target project and at the same level
4. Write tests following the conventions in `testing-strategy.md`

## Files

-   `create-test-project.ps1` — Creates and configures the test project
-   `testing-strategy.md` — Testing conventions and naming

## What the Script Does

1. Creates new xUnit project named `{ProjectName}.UnitTests`
2. Adds it to the solution
3. Installs packages: AwesomeAssertions, NSubstitute, AutoFixture
4. Adds project reference to the source project
5. Runs a clean build to verify setup

## After Creation

Once the project exists, write tests following `testing-strategy.md` conventions.

