wshaddix/dotnet-skills/dotnet-add-testing
Claude Code and agent skill by wshaddix/dotnet-skills
- community
Checking that the SKILL.md file is still in the repository.
Adding test infrastructure to a .NET project. Scaffolds xUnit project, coverlet, layout.
Install
npx vskill@latest install wshaddix/dotnet-skills/dotnet-add-testingSKILL.md
dotnet-add-testing
Add test infrastructure scaffolding to an existing .NET project. Creates test projects with xUnit, configures code coverage with coverlet, and sets up the conventional directory structure.
Scope boundary: This skill provides test project scaffolding only. For in-depth testing patterns -- xUnit v3 features, integration testing with WebApplicationFactory, UI testing, snapshot testing, test quality metrics, and testing strategy guidance -- see [skill:dotnet-testing-strategy] and the related testing skills.
Prerequisites: Run [skill:dotnet-version-detection] first to determine SDK version and TFM. Run [skill:dotnet-project-analysis] to understand existing solution structure.
Cross-references: [skill:dotnet-project-structure] for overall solution layout conventions, [skill:dotnet-scaffold-project] which includes test scaffolding in new projects, [skill:dotnet-add-analyzers] for test-specific analyzer suppressions.
Test Project Structure
Follow the convention of mirroring src/ project names under tests/:
Naming conventions:
*.UnitTests-- isolated tests with no external dependencies*.IntegrationTests-- tests that use real infrastructure (database, HTTP, file system)*.FunctionalTests-- end-to-end tests through the full application stack
Step 1: Create the Test Project
Clean Up Generated Project
Remove properties already defined in Directory.Build.props:
With CPM, Version attributes are managed in Directory.Packages.props. Remove them from the generated .csproj.
Step 2: Add Test-Specific Build Properties
Create tests/Directory.Build.props to customize settings for all test projects:
This imports the root Directory.Build.props (for shared settings like Nullable, ImplicitUsings, LangVersion) and overrides test-specific properties.
Step 3: Register Test Packages in CPM
Add test package versions to Directory.Packages.props:
Optional: Mocking Library
Add a mocking library if the project needs test doubles:
Or for assertion libraries:
Step 4: Configure Code Coverage
Coverlet (Collector Mode)
The coverlet.collector package integrates with dotnet test via the data collector. No additional configuration is needed for basic coverage.
Generate coverage reports:
Coverage Thresholds
For CI enforcement, use coverlet.msbuild for threshold checks:
Coverage Report Generation
Use reportgenerator for human-readable HTML reports:
Step 5: Add EditorConfig Overrides for Tests
In the root .editorconfig, add test-specific relaxations:
Step 6: Write a Starter Test
Replace the template-generated UnitTest1.cs with a properly structured test:
Test Naming Convention
Use the pattern Method_Condition_ExpectedResult:
CreateUser_WithValidInput_ReturnsUserGetById_WhenNotFound_ReturnsNullDelete_WithoutPermission_ThrowsUnauthorized
Verify
After adding test infrastructure, verify everything works:
Adding Integration Test Projects
For integration tests that need WebApplicationFactory or database access:
Add integration test packages to CPM (match the Microsoft.AspNetCore.Mvc.Testing major version to the target framework -- e.g., 8.x for net8.0, 9.x for net9.0, 10.x for net10.0):
Integration test depth (WebApplicationFactory patterns, test containers, database fixtures) -- see [skill:dotnet-integration-testing].
What's Next
This skill covers test project scaffolding. For deeper testing guidance:
- xUnit v3 features and patterns -- [skill:dotnet-xunit]
- Integration testing with WebApplicationFactory -- [skill:dotnet-integration-testing]
- UI testing (Blazor, MAUI, Uno) -- [skill:dotnet-blazor-testing], [skill:dotnet-maui-testing], [skill:dotnet-uno-testing]
- Snapshot testing -- [skill:dotnet-snapshot-testing]
- Test quality and coverage enforcement -- [skill:dotnet-test-quality]
- CI test reporting -- [skill:dotnet-add-ci] for starter, [skill:dotnet-gha-build-test] and [skill:dotnet-ado-build-test] for advanced
References
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/dotnet-add-testing/SKILL.md
Popularity
- Repository stars
- 86
- Repository forks
- 14
- 7-day trend score
- 3
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 18 Mar 2026, 7 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/wshaddix/dotnet-skills/dotnet-add-testing)