generate-unit-test

Generate NUnit test skeletons with mock setup for .cs files.

Updated Mar 1, 2026
One-click install
npx skills add https://github.com/CloudyWing/ai-dotfiles --skill generate-unit-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: generate-unit-test
Source: https://github.com/CloudyWing/ai-dotfiles/tree/main/skills/generate-unit-test
Command: npx skills add https://github.com/CloudyWing/ai-dotfiles --skill generate-unit-test

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Developers spend repetitive time writing boilerplate unit tests and setting up mocks for C# classes; this Skill automates the creation of NUnit test skeletons so engineers can focus on test logic rather than structure and setup.

Core Features & Use Cases

  • Automatic test skeletons: Generates NUnit test classes per C# class with Arrange/Act/Assert structure and standard naming conventions.
  • Mock wiring: Detects constructor dependencies and creates NSubstitute mocks, including async method templates and IDisposable handling.
  • Project integration: Locates or prompts for the test project, ensures conventional test file placement, and appends missing test methods without overwriting existing tests.
  • Use Case: Convert a service class with multiple public methods into a ready-to-edit test file that includes Happy Path tests, null/exception cases, and collection result edge cases.

Quick Start

Use /generate-unit-test with the target class name or .cs file path to generate NUnit tests with NSubstitute mocks and standard AAA structure.

Frequently Asked Questions about generate-unit-test

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

FAQPage Schema
How do I auto-generate NUnit test skeletons for C# classes?

To auto-generate NUnit test skeletons for C#, target a class name or .cs file path to produce test classes with Arrange/Act/Assert structure, NSubstitute mock initialization, and standard naming conventions automatically.

Does this test generation tool create NSubstitute mocks for constructor dependencies?

Yes, the test generation process detects constructor dependencies and creates NSubstitute mocks automatically, including async method templates and IDisposable handling for comprehensive mock setup.

What is the best way to add missing test methods to existing NUnit files?

The best way to add missing test methods is appending them to existing NUnit test files without overwriting current tests, ensuring conventional test file placement within matching test projects.

Can I use this to generate unit tests for async methods in dotnet repositories?

You can use this to generate unit tests for async methods in dotnet repositories by producing NUnit test classes that include async method templates and IDisposable patterns for C# service classes.

How does it locate or create matching test projects for common dotnet patterns?

It locates or prompts for the test project by applying to .cs source files in typical dotnet repository layouts, finding or creating matching test projects for common patterns like tests/** or *.Tests.

What unit test cases are generated for a C# service class with multiple public methods?

Generated unit test cases for a C# service class include Happy Path tests, null/exception cases, and collection result edge cases, structured with Arrange/Act/Assert format and NSubstitute mocks.