Code Testing Generation Skill
An AI-powered skill that generates comprehensive, workable unit tests for any programming language using a coordinated multi-agent pipeline.
When to Use This Skill
Use this skill when you need to:
- Generate unit tests for an entire project or specific files
- Improve test coverage for existing codebases
- Create test files that follow project conventions
- Write tests that actually compile and pass
- Add tests for new features or untested code
When Not to Use
- Running or executing existing tests (use the
run-tests skill)
- Migrating between test frameworks (use migration skills)
- Writing tests specifically for MSTest patterns (use
writing-mstest-tests)
- Debugging failing test logic
How It Works
This skill coordinates multiple specialized agents in a Research → Plan → Implement pipeline:
Pipeline Overview
┌─────────────────────────────────────────────────────────────┐
│ TEST GENERATOR │
│ Coordinates the full pipeline and manages state │
└─────────────────────┬───────────────────────────────────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌───────────┐ ┌───────────┐ ┌───────────────┐
│ RESEARCHER│ │ PLANNER │ │ IMPLEMENTER │
│ │ │ │ │ │
│ Analyzes │ │ Creates │ │ Writes tests │
│ codebase │→ │ phased │→ │ per phase │
│ │ │ plan │ │ │
└───────────┘ └───────────┘ └───────┬───────┘
│
┌─────────┬───────┼───────────┐
▼ ▼ ▼ ▼
┌─────────┐ ┌───────┐ ┌───────┐ ┌───────┐
│ BUILDER │ │TESTER │ │ FIXER │ │LINTER │
│ │ │ │ │ │ │ │
│ Compiles│ │ Runs │ │ Fixes │ │Formats│
│ code │ │ tests │ │ errors│ │ code │
└─────────┘ └───────┘ └───────┘ └───────┘
Step-by-Step Instructions
Step 1: Determine the user request
Make sure you understand what user is asking and for what scope.
When the user does not express strong requirements for test style, coverage goals, or conventions, source the guidelines from unit-test-generation.prompt.md. This prompt provides best practices for discovering conventions, parameterization strategies, coverage goals (aim for 80%), and language-specific patterns.
Step 2: Invoke the Test Generator
Start by calling the code-testing-generator agent with your test generation request:
Generate unit tests for [path or description of what to test], following the [unit-test-generation.prompt.md](unit-test-generation.prompt.md) guidelines
The Test Generator will manage the entire pipeline automatically.
Step 3: Research Phase (Automatic)
The code-testing-researcher agent analyzes your codebase to understand:
- Language & Framework: Detects C#, TypeScript, Python, Go, Rust, Java, etc.
- Testing Framework: Identifies MSTest, xUnit, Jest, pytest, go test, etc.
- Project Structure: Maps source files, existing tests, and dependencies
- Build Commands: Discovers how to build and test the project
For C# / .NET repos with a multi-file scope, the researcher should prefer the find-untested-sources skill (when available) over manual find/grep/glob walks to build the source-to-test pairing map. It is a parse-only Roslyn analyzer (no build, no coverage — seconds on multi-thousand-file repos) that emits a deterministic JSON list of untested files ordered by API surface, plus a suggested_test_path derived from <ProjectReference> edges.
Output: .testagent/research.md
Step 4: Planning Phase (Automatic)
The code-testing-planner agent creates a structured implementation plan:
- Groups files into logical phases (2-5 phases typical)
- Prioritizes by complexity and dependencies
- Specifies test cases for each file
- Defines success criteria per phase
Output: .testagent/plan.md
Step 5: Implementation Phase (Automatic)
The code-testing-implementer agent executes each phase sequentially:
- Read source files to understand the API
- Write test files following project patterns
- Build using the
code-testing-builder sub-agent to verify compilation
- Test using the
code-testing-tester sub-agent to verify tests pass
- Fix using the
code-testing-fixer sub-agent if errors occur
- Lint using the
code-testing-linter sub-agent for code formatting
Each phase completes before the next begins, ensuring incremental progress.
Coverage Types
- Happy path: Valid inputs produce expected outputs
- Edge cases: Empty values, boundaries, special characters
- Error cases: Invalid inputs, null handling, exceptions
State Management
All pipeline state is stored in .testagent/ folder:
| File |
Purpose |
.testagent/research.md |
Codebase analysis results |
.testagent/plan.md |
Phased implementation plan |
.testagent/status.md |
Progress tracking (optional) |
Examples
Strategy Selection
The generator picks a strategy based on request scope:
| User Request |
Strategy |
Why |
"Generate tests for src/services/UserService.ts" |
Direct |
Single file, small scope — write tests immediately, skip sub-agents (but still run the generator's Step 7 pre-completion gate — test-gap-analysis + assertion-quality — before finishing) |
| "Add unit tests for my billing project" |
Single pass |
Moderate scope — one Research → Plan → Implement cycle covers it |
| "Achieve 80% coverage across the entire solution" |
Iterative |
Large scope — multiple R→P→I cycles, each narrowing remaining gaps |
Pipeline Walkthrough
Given a request like "Generate unit tests for my InvoiceService", the pipeline produces:
- Research →
.testagent/research.md containing detected language/framework, build commands, files to test ranked by priority, and existing test inventory
- Plan →
.testagent/plan.md containing phased approach with specific methods and test scenarios (happy path, edge cases, error cases) for each file
- Implement → Test files written, built, and verified per phase. Fix cycle runs automatically if build/test errors occur
- Validate → Full workspace build + full test run to catch cross-project issues
- Report → Summary of tests created, pass/fail counts, coverage notes, and next steps
Language-Specific Examples
The code-testing-extensions skill provides concrete, filled-in examples for each pipeline phase showing real source code, real research output, real plans, and real generated tests. Call the code-testing-extensions skill to discover available extension files, then read:
dotnet-examples.md — MSTest example with InvoiceService: research output, plan output, generated test file, fix cycle walkthrough, and final report
python-examples.md — pytest example with the same InvoiceService scenario: research, plan, generated test file (parametrized, unittest.mock), fix cycles (ModuleNotFoundError, patch target, Mock(spec=...)), and final report
typescript-examples.md — Vitest example (also applicable to Jest) showing it.each parameterization, async tests, fake timers, and ESM/CJS fix cycles
go-examples.md — Standard testing package example with table-driven subtests, hand-written fake repository, injected clock, and -run regex fix cycle
java-examples.md — JUnit 5 + Mockito example on Maven showing @ExtendWith(MockitoExtension.class), @ParameterizedTest + @CsvSource, Clock.fixed(...) for time, and Surefire fix cycles
For languages without a dedicated examples file (Rust, Ruby, Swift, Kotlin, C++, PowerShell), use the base extension file (<language>.md) plus the example file for the closest paradigm — the pipeline shape (research → plan → generate → fix) and the categories of decisions (test layout, mocking strategy, fixed clock for time-dependent code, parameterization style) translate directly.
Agent Reference
| Agent |
Purpose |
code-testing-generator |
Coordinates pipeline |
code-testing-researcher |
Analyzes codebase |
code-testing-planner |
Creates test plan |
code-testing-implementer |
Writes test files |
code-testing-builder |
Compiles code |
code-testing-tester |
Runs tests |
code-testing-fixer |
Fixes errors |
code-testing-linter |
Formats code |
Requirements
- Project must have a build/test system configured
- Testing framework should be installed (or installable)
- VS Code with GitHub Copilot extension
Troubleshooting
Tests don't compile
The code-testing-fixer agent will attempt to resolve compilation errors. Check .testagent/plan.md for the expected test structure. Call the code-testing-extensions skill and read the language-specific extension file for error code references (e.g., dotnet.md for .NET).
Tests fail
Most failures in generated tests are caused by wrong expected values in assertions, not production code bugs:
- Read the actual test output
- Read the production code to understand correct behavior
- Fix the assertion, not the production code
- Never mark tests
[Ignore] or [Skip] just to make them pass
Wrong testing framework detected
Specify your preferred framework in the initial request: "Generate Jest tests for..."
Environment-dependent tests fail
Tests that depend on external services, network endpoints, specific ports, or precise timing will fail in CI environments. Focus on unit tests with mocked dependencies instead.
Build fails on full solution
During phase implementation, build only the specific test project for speed. After all phases, run a full non-incremental workspace build to catch cross-project errors.
1---2name: code-testing-agent3description: >-4 Generates and writes new unit tests for any programming language —5 scaffolds test projects and configures coverage tooling6 (coverlet, pytest-cov, @vitest/coverage-v8) as part of test7 generation. Use when asked to generate tests, generate pytest8 tests, generate Vitest tests, write unit tests, add tests, improve9 coverage, comprehensive tests, or scaffold a new test project or10 suite for an app, service, library, REST API, blueprint, or11 package — including project-wide, multi-file test generation12 across services, repositories, routes, and modules. Supports13 C#/.NET, Python (pytest, Flask/Django), TypeScript/JavaScript14 (Vitest, Jest, Mocha), Go, Rust, Java (JUnit). Runs a research,15 planning, and implementation pipeline so tests compile and pass.16 DO NOT USE FOR: running existing tests (use run-tests); analyzing17 existing coverage reports (use coverage-analysis or crap-score);18 writing, fixing, or modernizing MSTest-specific tests, assertions,19 attributes, or lifecycle (use writing-mstest-tests).20license: MIT21metadata:22 source: https://skillmd.com/skills/dotnet/code-testing-agent23---2425# Code Testing Generation Skill2627An AI-powered skill that generates comprehensive, workable unit tests for any programming language using a coordinated multi-agent pipeline.2829## When to Use This Skill3031Use this skill when you need to:3233- Generate unit tests for an entire project or specific files34- Improve test coverage for existing codebases35- Create test files that follow project conventions36- Write tests that actually compile and pass37- Add tests for new features or untested code3839## When Not to Use4041- Running or executing existing tests (use the `run-tests` skill)42- Migrating between test frameworks (use migration skills)43- Writing tests specifically for MSTest patterns (use `writing-mstest-tests`)44- Debugging failing test logic4546## How It Works4748This skill coordinates multiple specialized agents in a **Research → Plan → Implement** pipeline:4950### Pipeline Overview5152```text53┌─────────────────────────────────────────────────────────────┐54│ TEST GENERATOR │55│ Coordinates the full pipeline and manages state │56└─────────────────────┬───────────────────────────────────────┘57 │58 ┌─────────────┼─────────────┐59 ▼ ▼ ▼60┌───────────┐ ┌───────────┐ ┌───────────────┐61│ RESEARCHER│ │ PLANNER │ │ IMPLEMENTER │62│ │ │ │ │ │63│ Analyzes │ │ Creates │ │ Writes tests │64│ codebase │→ │ phased │→ │ per phase │65│ │ │ plan │ │ │66└───────────┘ └───────────┘ └───────┬───────┘67 │68 ┌─────────┬───────┼───────────┐69 ▼ ▼ ▼ ▼70 ┌─────────┐ ┌───────┐ ┌───────┐ ┌───────┐71 │ BUILDER │ │TESTER │ │ FIXER │ │LINTER │72 │ │ │ │ │ │ │ │73 │ Compiles│ │ Runs │ │ Fixes │ │Formats│74 │ code │ │ tests │ │ errors│ │ code │75 └─────────┘ └───────┘ └───────┘ └───────┘76```7778## Step-by-Step Instructions7980### Step 1: Determine the user request8182Make sure you understand what user is asking and for what scope.83When the user does not express strong requirements for test style, coverage goals, or conventions, source the guidelines from [unit-test-generation.prompt.md](unit-test-generation.prompt.md). This prompt provides best practices for discovering conventions, parameterization strategies, coverage goals (aim for 80%), and language-specific patterns.8485### Step 2: Invoke the Test Generator8687Start by calling the `code-testing-generator` agent with your test generation request:8889```text90Generate unit tests for [path or description of what to test], following the [unit-test-generation.prompt.md](unit-test-generation.prompt.md) guidelines91```9293The Test Generator will manage the entire pipeline automatically.9495### Step 3: Research Phase (Automatic)9697The `code-testing-researcher` agent analyzes your codebase to understand:9899- **Language & Framework**: Detects C#, TypeScript, Python, Go, Rust, Java, etc.100- **Testing Framework**: Identifies MSTest, xUnit, Jest, pytest, go test, etc.101- **Project Structure**: Maps source files, existing tests, and dependencies102- **Build Commands**: Discovers how to build and test the project103104For **C# / .NET** repos with a multi-file scope, the researcher should prefer the `find-untested-sources` skill (when available) over manual `find`/`grep`/`glob` walks to build the source-to-test pairing map. It is a parse-only Roslyn analyzer (no build, no coverage — seconds on multi-thousand-file repos) that emits a deterministic JSON list of untested files ordered by API surface, plus a `suggested_test_path` derived from `<ProjectReference>` edges.105106Output: `.testagent/research.md`107108### Step 4: Planning Phase (Automatic)109110The `code-testing-planner` agent creates a structured implementation plan:111112- Groups files into logical phases (2-5 phases typical)113- Prioritizes by complexity and dependencies114- Specifies test cases for each file115- Defines success criteria per phase116117Output: `.testagent/plan.md`118119### Step 5: Implementation Phase (Automatic)120121The `code-testing-implementer` agent executes each phase sequentially:1221231. **Read** source files to understand the API1242. **Write** test files following project patterns1253. **Build** using the `code-testing-builder` sub-agent to verify compilation1264. **Test** using the `code-testing-tester` sub-agent to verify tests pass1275. **Fix** using the `code-testing-fixer` sub-agent if errors occur1286. **Lint** using the `code-testing-linter` sub-agent for code formatting129130Each phase completes before the next begins, ensuring incremental progress.131132### Coverage Types133134- **Happy path**: Valid inputs produce expected outputs135- **Edge cases**: Empty values, boundaries, special characters136- **Error cases**: Invalid inputs, null handling, exceptions137138## State Management139140All pipeline state is stored in `.testagent/` folder:141142| File | Purpose |143| ------------------------ | ---------------------------- |144| `.testagent/research.md` | Codebase analysis results |145| `.testagent/plan.md` | Phased implementation plan |146| `.testagent/status.md` | Progress tracking (optional) |147148## Examples149150### Strategy Selection151152The generator picks a strategy based on request scope:153154| User Request | Strategy | Why |155|---|---|---|156| "Generate tests for `src/services/UserService.ts`" | **Direct** | Single file, small scope — write tests immediately, skip sub-agents (but still run the generator's Step 7 pre-completion gate — `test-gap-analysis` + `assertion-quality` — before finishing) |157| "Add unit tests for my billing project" | **Single pass** | Moderate scope — one Research → Plan → Implement cycle covers it |158| "Achieve 80% coverage across the entire solution" | **Iterative** | Large scope — multiple R→P→I cycles, each narrowing remaining gaps |159160### Pipeline Walkthrough161162Given a request like *"Generate unit tests for my InvoiceService"*, the pipeline produces:1631641. **Research** → `.testagent/research.md` containing detected language/framework, build commands, files to test ranked by priority, and existing test inventory1652. **Plan** → `.testagent/plan.md` containing phased approach with specific methods and test scenarios (happy path, edge cases, error cases) for each file1663. **Implement** → Test files written, built, and verified per phase. Fix cycle runs automatically if build/test errors occur1674. **Validate** → Full workspace build + full test run to catch cross-project issues1685. **Report** → Summary of tests created, pass/fail counts, coverage notes, and next steps169170### Language-Specific Examples171172The `code-testing-extensions` skill provides concrete, filled-in examples for each pipeline phase showing real source code, real research output, real plans, and real generated tests. Call the `code-testing-extensions` skill to discover available extension files, then read:173174- **`dotnet-examples.md`** — MSTest example with InvoiceService: research output, plan output, generated test file, fix cycle walkthrough, and final report175- **`python-examples.md`** — pytest example with the same InvoiceService scenario: research, plan, generated test file (parametrized, `unittest.mock`), fix cycles (`ModuleNotFoundError`, patch target, `Mock(spec=...)`), and final report176- **`typescript-examples.md`** — Vitest example (also applicable to Jest) showing `it.each` parameterization, async tests, fake timers, and ESM/CJS fix cycles177- **`go-examples.md`** — Standard `testing` package example with table-driven subtests, hand-written fake repository, injected clock, and `-run` regex fix cycle178- **`java-examples.md`** — JUnit 5 + Mockito example on Maven showing `@ExtendWith(MockitoExtension.class)`, `@ParameterizedTest` + `@CsvSource`, `Clock.fixed(...)` for time, and Surefire fix cycles179180For languages without a dedicated examples file (Rust, Ruby, Swift, Kotlin, C++, PowerShell), use the base extension file (`<language>.md`) plus the example file for the closest paradigm — the pipeline shape (research → plan → generate → fix) and the categories of decisions (test layout, mocking strategy, fixed clock for time-dependent code, parameterization style) translate directly.181182## Agent Reference183184| Agent | Purpose |185| -------------------------- | -------------------- |186| `code-testing-generator` | Coordinates pipeline |187| `code-testing-researcher` | Analyzes codebase |188| `code-testing-planner` | Creates test plan |189| `code-testing-implementer` | Writes test files |190| `code-testing-builder` | Compiles code |191| `code-testing-tester` | Runs tests |192| `code-testing-fixer` | Fixes errors |193| `code-testing-linter` | Formats code |194195## Requirements196197- Project must have a build/test system configured198- Testing framework should be installed (or installable)199- VS Code with GitHub Copilot extension200201## Troubleshooting202203### Tests don't compile204205The `code-testing-fixer` agent will attempt to resolve compilation errors. Check `.testagent/plan.md` for the expected test structure. Call the `code-testing-extensions` skill and read the language-specific extension file for error code references (e.g., `dotnet.md` for .NET).206207### Tests fail208209Most failures in generated tests are caused by **wrong expected values in assertions**, not production code bugs:2102111. Read the actual test output2122. Read the production code to understand correct behavior2133. Fix the assertion, not the production code2144. Never mark tests `[Ignore]` or `[Skip]` just to make them pass215216### Wrong testing framework detected217218Specify your preferred framework in the initial request: "Generate Jest tests for..."219220### Environment-dependent tests fail221222Tests that depend on external services, network endpoints, specific ports, or precise timing will fail in CI environments. Focus on unit tests with mocked dependencies instead.223224### Build fails on full solution225226During phase implementation, build only the specific test project for speed. After all phases, run a full non-incremental workspace build to catch cross-project errors.