Generates test suite for existing code. Use when adding unit or integration tests to untested code.
From dotnet-ai-kitnpx claudepluginhub faysilalshareef/dotnet-ai-kit --plugin dotnet-ai-kit/add-testsAdds tests for specified file path or function, or recently changed files lacking coverage; covers happy paths, edge cases, errors, and verifies by running tests.
/add-testsAdds tests for specified file path or function, or recently changed files lacking coverage; covers happy paths, edge cases, errors, and verifies by running tests.
/add-testsGenerates and adds test coverage for a specific plan or phase post-execution. Specify [N] for the target plan or phase number.
/add-testsGenerates comprehensive test suites for React components or API endpoints using Jest and React Testing Library, covering unit, integration, accessibility, interactions, and edge cases.
Scan existing code for classes, handlers, and controllers without test files and generate missing tests. Detects the test framework, mocking library, and follows existing test patterns.
/dotnet-ai.add-tests $ARGUMENTS
Examples:
OrderService -- Generate tests for a specific class--handlers -- Generate tests for all MediatR handlers--coverage 80 -- Generate tests until estimated 80% coverage--dry-run -- Show what tests would be generated--list -- Show file list only--verbose -- Show scanning and detection details| Flag | Description |
|---|---|
--handlers | Target all MediatR/CQRS handlers only |
--controllers | Target all controllers only |
--services | Target all service classes only |
--coverage {N} | Generate tests targeting N% coverage estimate |
--dry-run | Display generated test code without writing |
--list | List test files that would be created with descriptions, no code output |
--verbose | Show scanning progress, pattern detection, coverage estimates |
--no-build | Skip post-generation build and test run |
.csproj with test SDK reference).
[Fact], [Theory], Xunit namespace[Test], [TestCase], NUnit.Framework[TestMethod], [TestClass], Microsoft.VisualStudio.TestToolsMock<T>, Moq namespaceSubstitute.For<T>, NSubstitute namespaceA.Fake<T>, FakeItEasy namespace{Class}Tests, {Class}Should, When{Action}_{Result})CustomConstructorFaker, Bogus Faker<T>){Handler}Tests.cs{Controller}Tests.cs{Service}Tests.cs--handlers, --controllers, specific class name)Read agents/test-engineer.md for testing patterns. Also read the project's primary architect agent for architecture context:
agents/command-architect.mdagents/query-architect.mdagents/cosmos-architect.mdagents/processor-architect.mdagents/gateway-architect.mdagents/controlpanel-architect.mdagents/command-architect.md and agents/query-architect.mdagents/dotnet-architect.mdLoad all skills listed in each loaded agent's Skills Loaded section.
skills/testing/unit-testing -- unit test structure, assertions, mocking patternsskills/testing/integration-testing -- integration test setup, WebApplicationFactoryskills/testing/test-fixtures -- shared fixtures, test data builders, fakers--coverage {N} specified: prioritize by impact (handlers first, then services, then controllers)For Handlers:
Test/Commands/{Handler}Tests.cs or matching existing structureFor Controllers/Endpoints:
Test/Controllers/{Controller}Tests.csFor Services:
Test/Services/{Service}Tests.csFor Validators:
Test/Validators/{Validator}Tests.csTest/Integration/{Feature}IntegrationTests.csWebApplicationFactory or custom test server pattern from existing testsdotnet build on test project -- verify compilation.dotnet test -- verify generated tests pass.Generated {N} test files with {M} test methods.
- Handlers: {X} tested
- Controllers: {Y} tested
- Services: {Z} tested
All tests passing.
--dry-run: Show generated test code with file headers. No writes.--list: List test files that would be created with class counts. No code, no writes.