testpilot-dotnet
v0.1.4
Published
AI-powered .NET unit test gap finder and generator
Downloads
583
Readme
testpilot-dotnet
AI-powered unit test gap finder and writer for .NET projects.
TestPilot scans your ASP.NET Core, Optimizely CMS, or Umbraco CMS project, finds classes with missing or incomplete tests, and writes production-ready unit tests using Claude AI — matching your team's existing style, frameworks, and naming conventions.
Installation
No installation needed — use npx:
npx testpilot-dotnet <command>Or install globally:
npm install -g testpilot-dotnet
testpilot-dotnet <command>Requirements
- Node.js 18+
- .NET SDK 6 / 8 / 9 / 10
- Anthropic API key set as an environment variable:
# Windows
set ANTHROPIC_API_KEY=sk-ant-...
# macOS / Linux
export ANTHROPIC_API_KEY=sk-ant-...Get an API key at console.anthropic.com.
Quick Start
Run these commands inside your .NET solution directory:
npx testpilot-dotnet init # Detect project configuration
npx testpilot-dotnet scan # Find missing tests
npx testpilot-dotnet report # View the gap report
npx testpilot-dotnet generate # Write the missing testsCI Integration (GitHub Actions)
TestPilot can run automatically on every push and commit generated tests back to your branch.
One-time setup — run this in your .NET project:
npx testpilot-dotnet ci-setupThis creates .github/workflows/testpilot.yml in your repo. Then:
- Add your Anthropic API key as a GitHub secret:
- Repo → Settings → Secrets → Actions → New repository secret
- Name:
ANTHROPIC_API_KEY
- Commit and push the workflow file
From that point on, every push to a feature branch will:
- Detect which source files changed
- Scan those files for missing tests
- Generate and build-verify the tests
- Commit the test files back to the same branch automatically
Commits made by TestPilot include [testpilot skip] so they never retrigger the workflow.
Commands
testpilot-dotnet init
Scans your solution and creates a .testpilot.json config file. Reads all .csproj files to auto-detect your test framework, mocking library, and CMS version.
| Option | Description |
|---|---|
| -y, --yes | Overwrite existing config without prompting |
testpilot-dotnet scan
Analyzes your source code and existing tests, then produces a gap report saved to .testpilot.gaps.json.
testpilot-dotnet generate
Generates missing test files based on the gap report.
| Option | Description |
|---|---|
| --dry-run | Preview what would be generated without writing files |
| --max-files <n> | Limit number of test files to generate |
| --file <path> | Generate tests for a specific source file only |
| --gap-type <type> | Filter by gap type: no-test-class, no-tests, missing-scenarios |
| --min-priority <level> | Minimum priority: critical, high, medium, low |
testpilot-dotnet report
Displays the gap report in the terminal.
| Option | Description |
|---|---|
| --output terminal | Human-readable output (default) |
| --output json | JSON format |
| --output markdown | Markdown format |
testpilot-dotnet ci-setup
Generates a GitHub Actions workflow file that runs TestPilot on every push.
| Option | Description |
|---|---|
| --platform <name> | CI platform: github (default) |
| --dotnet-version <ver> | .NET SDK version for the workflow (default: 8.x) |
| --node-version <ver> | Node.js version for the workflow (default: 20) |
testpilot-dotnet ci-run
Runs the full CI pipeline: detect changed files → scan → generate → optionally commit. Intended for use inside CI pipelines, not locally.
| Option | Description |
|---|---|
| --commit | Commit and push generated test files back to the branch |
| --base <sha> | Git SHA to diff against (defaults to HEAD~1 or TESTPILOT_BASE_SHA env var) |
Supported Frameworks
| Category | Supported | |---|---| | Test frameworks | xUnit, NUnit, MSTest | | Mocking | Moq, NSubstitute, FakeItEasy | | Test data | AutoFixture, Bogus | | CMS | Optimizely CMS 12+, Umbraco CMS 13+ / 17+ | | .NET versions | .NET 6, 8, 9, 10+ |
All frameworks are auto-detected from your .csproj PackageReference elements — no manual configuration needed.
Configuration
testpilot-dotnet init creates a .testpilot.json file. All fields default to "auto":
{
"solution": "./MySite.sln",
"sourceProjects": ["src/MySite.Web"],
"testProjects": ["tests/MySite.Web.Tests"],
"testFramework": "auto",
"mockingLibrary": "auto",
"namingConvention": "MethodName_Scenario_ExpectedResult",
"patterns": {
"include": ["**/*.cs"],
"exclude": ["**/Migrations/**", "**/obj/**"]
}
}How It Works
- Detect — Reads
.csprojfiles to identify frameworks, libraries, and CMS version - Scan — Analyzes source classes to find testable methods and business logic
- Match — Compares source against existing tests to find gaps
- Generate — Uses Claude AI to write tests matching your team's style
- Verify — Runs
dotnet buildto ensure generated tests compile, auto-fixes up to 3 times
What TestPilot Will NOT Do
- Modify your source code — it only writes inside test projects
- Test auto-generated code (EF migrations,
.g.cs, designer files) - Overwrite existing test methods — it appends only
- Generate tests for thin CRUD-delegation classes with no real logic
