Generated banner for Code Testing Extensions
Generated logo for Code Testing Extensions

Code Testing Extensions

.NET (Microsoft)OfficialPublished by .NET (Microsoft)

  • Skill
  • Guidelines
  • Software development
  • MIT
  • Low risk

From the author

Provides file paths to language-specific extension files for the code-testing pipeline. Read this reference-only catalog for extension guidance files (e.g., dotnet.md for .NET, cpp.md for C++). Agents and skills read its bundled files directly; do not invoke this catalog through the model's skill tool.
— the description by .NET (Microsoft)

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

Code Testing Extensions is a non-invocable reference library designed to support automated testing workflows. It provides a structured collection of documentation files covering various programming languages, including .NET, Python, TypeScript, Go, Java, and more. Each entry offers essential guidance on build and test commands, framework-specific patterns, mocking strategies, and common error resolution. Additionally, the catalog includes example files that demonstrate complete testing pipeline cycles, from research and planning to test generation and reporting.

What it does

  • Provides language-specific testing guidance for multiple programming environments.
  • Lists standard build and test commands for various testing frameworks.
  • Offers best practices for mocking, project layout, and framework detection.
  • Includes concrete examples of full testing pipeline workflows.
  • Serves as a centralized reference for agents to ensure consistent testing standards.

When to use it

  • When an agent needs to determine the correct testing commands for a specific language.
  • When implementing or debugging a testing pipeline for a new project.
  • When guidance on framework-specific mocking or test structure is required.
  • When looking for representative examples of a complete test generation cycle.

Advantages

  • Ensures consistency across different testing environments.
  • Reduces ambiguity by providing standardized commands and patterns.
  • Provides both high-level guidance and concrete implementation examples.
  • Supports a wide range of modern programming languages and frameworks.

Usage examples

“Read extensions/python.md to understand the preferred testing patterns for a pytest project.”
The agent retrieves the Python-specific guidance, identifying the correct test runner commands and mocking strategies to apply.
“Consult extensions/java-examples.md to see how to structure a JUnit 5 test suite.”
The agent reviews the provided example to replicate the established project structure and testing conventions for the Java codebase.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/dotnet/code-testing-extensions/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip code-testing-extensions.zip -d .agents/skills

Documentation by .NET (Microsoft)

Code Testing Extensions

This reference-only catalog lists bundled guidance for the code-testing pipeline. Read the matching file directly; do not invoke this catalog as a skill. Resource paths are relative to this catalog, not the project workspace.

Available Extension Files

FileLanguageContents
extensions/dotnet.md.NET (C#/F#/VB)Build commands, test commands, project reference validation, common CS error codes, MSTest template
extensions/python.mdPythonFramework-adaptive test commands (pytest, custom runners), project layout detection, mocking guidelines, common errors
extensions/typescript.mdTypeScript/JavaScriptBuild/test commands (Jest/Vitest/Mocha), framework detection, mocking, TS-specific considerations
extensions/powershell.mdPowerShellTest commands (Pester v5), module import patterns, discovery/run pitfalls, mocking, common errors
extensions/cpp.mdC++Testing internals with friend declarations
extensions/go.mdGogo test commands, table-driven tests, integration vs unit layout, mocking via interfaces, common errors
extensions/java.mdJavaMaven/Gradle commands, JUnit 4/5 and TestNG detection, Mockito, Spring Boot slices, common errors
extensions/rust.mdRustcargo test commands, unit vs integration vs doc tests, features, async test harnesses, common errors
extensions/ruby.mdRubyRSpec and Minitest commands, Bundler usage, Rails specifics, mocking patterns, common errors
extensions/swift.mdSwiftSPM and Xcode test commands, XCTest vs Swift Testing, @testable import, async/throws tests, common errors
extensions/kotlin.mdKotlinGradle commands, JUnit/Kotest detection, MockK, coroutines test, KMP and Android specifics, common errors
extensions/dotnet-examples.md.NET (C#/F#/VB)Concrete pipeline examples: sample research output, plan, generated tests, fix cycles, final report
extensions/python-examples.mdPythonConcrete pipeline examples (pytest): research, plan, generated test file, fix cycles, final report
extensions/typescript-examples.mdTypeScript/JavaScriptConcrete pipeline examples (Vitest, applicable to Jest): research, plan, generated test file, fix cycles, final report
extensions/go-examples.mdGoConcrete pipeline examples (standard testing): research, plan, table-driven test file, fix cycles, final report
extensions/java-examples.mdJavaConcrete pipeline examples (JUnit 5 + Mockito on Maven): research, plan, generated test file, fix cycles, final report

Usage

Read the appropriate base extension before writing test code. Load an <language>-examples.md file only when the repository has no representative tests and the base extension does not resolve the needed pattern. Do not load end-to-end examples for a focused request with established local conventions.

Files

extensions/go.md

Go Extension

Language-specific guidance for Go test generation.

Rule #1: Investigate the Repo First

Before writing any test or running any command, read:

  1. Existing tests — find *_test.go files and copy their style (table-driven layout, helper usage, assertion library, build tags)

  2. go.mod / go.sum — module path, Go version, dependencies (e.g. testify, gomock, mockery)

  3. Build/CI scripts — Makefile, magefile.go, Taskfile.yml, .github/workflows/*.yml

  4. go.work — if present, you are in a workspace; tests for a module must run from that module's directory or use -C (Go 1.20+)

Use whatever assertion style and test layout the repo already uses. Do not introduce testify if the repo uses the standard library only.

Toolchain Detection

IndicatorMeaning
go.mod go 1.x directiveMinimum Go version — match it locally with go version
go.work at the rootMulti-module workspace; commands resolve dependent modules from sibling directories
vendor/ directoryVendored deps; many commands implicitly add -mod=vendor
tools.go with //go:build toolsTool versions pinned in go.mod (e.g. mockgen); install with go install from the listed paths

Build Commands

ScopeCommand
Compile a packagego build ./path/to/pkg
Vet (static analysis)go vet ./...
Compile tests without runninggo test -count=1 -run=^$ ./path/to/pkg
Whole modulego build ./...

go build ./... is the closest thing to a "does it compile" gate. It does not exercise test files — use go test -run=^$ to type-check tests as well.

Test Commands

ScopeCommand
All tests in a packagego test ./path/to/pkg
All tests in modulego test ./...
Single testgo test -run '^TestName$' ./path/to/pkg
Subtestgo test -run '^TestName$/^subname$' ./path/to/pkg
Verbosego test -v ./path/to/pkg
Race detectorgo test -race ./...
Disable cachego test -count=1 ./...
Short modego test -short ./...
  • -run arguments are regular expressions anchored with ^...$; without anchors the pattern matches as a substring

  • go test -count=1 is the canonical way to bypass the test result cache; never use a fake -count=2 or environment hacks

  • -race significantly slows tests and requires CGO — only enable if the repo's CI does

Lint Command

Use the repo's lint script first (make lint, task lint). Otherwise detect from .golangci.yml/.golangci.yaml:

  • .golangci.yml present → golangci-lint run ./...

  • No config → gofmt -w . and go vet ./...

  • goimports config / pre-commit hook → goimports -w path/to/file.go

Never disable existing linters in the test files you generate.

Project Layout and Imports

Go uses package paths derived from the module path in go.mod.

ScenarioTest placementPackage declaration
Internal-only test (white-box)foo_test.go next to foo.gopackage foo (same as production)
External-only test (black-box)foo_test.go next to foo.gopackage foo_test (forces use of public API)
Integration / build-tag gatedfoo_integration_test.goAdd //go:build integration at top
  • Test files must end with _test.go — the toolchain ignores other names

  • A package directory may contain both package foo and package foo_test test files simultaneously

  • Helpers shared across tests in one package go in helpers_test.go — do not export them; put them in the _test package only if integration tests in another package need them

  • Imports use the full module path: import "github.com/org/module/pkg" — copy the exact module path from go.mod

Test Function Signatures

KindSignature
Standard testfunc TestThing(t *testing.T)
Subtestst.Run("name", func(t *testing.T) { ... })
Benchmarkfunc BenchmarkThing(b *testing.B)
Example (godoc)func ExampleThing() with // Output: comment
Fuzz (Go 1.18+)func FuzzThing(f *testing.F)
Per-package setupfunc TestMain(m *testing.M) — call m.Run() and os.Exit with its code

Use table-driven tests when generating multiple cases for the same behavior — this is idiomatic Go and matches what most repos already use:

func TestAdd(t *testing.T) {
    tests := []struct {
        name string
        a, b int
        want int
    }{
        {"positives", 2, 3, 5},
        {"negatives", -1, -1, -2},
    }
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            if got := Add(tt.a, tt.b); got != tt.want {
                t.Errorf("Add(%d,%d) = %d, want %d", tt.a, tt.b, got, tt.want)
            }
        })
    }
}

When iterating with t.Run over a loop variable on Go < 1.22, capture it with tt := tt to avoid closure-over-loop-variable bugs.

Common Errors

ErrorFix
package X is not in std / cannot find module providing package XAdd the import to go.mod: go get path/to/module@version, then go mod tidy
import cycle not allowed in testMove shared helpers to a separate package, or switch to a _test package for black-box tests
undefined: X in _test packageThe symbol is unexported; either use package foo (white-box) or export it intentionally
t.Parallel called multiple timesEach subtest can call t.Parallel() once; do not call it twice in the same test
panic: test executed panic(nil) or runtime.GoexitA goroutine called t.Fatal outside the test goroutine; only the main test goroutine may call Fatal/FailNow
flag provided but not defined: -XFlags registered in init() of test files must use flag.NewFlagSet carefully; place test-only flags in TestMain
go: cannot find main moduleRun inside the module directory (where go.mod lives), or use -C path (Go 1.20+)
build constraints exclude all Go files in...Build tags filtered out every file — match the repo's tag with -tags=integration etc.
missing go.sum entry for moduleRun go mod download or go mod tidy
Race detector reports data raceFix the race; do not silence it. CGO must be enabled

Mocking Rules

Go has no reflection-based mocking framework that's universally adopted. Pick what the repo already uses:

  • Interfaces + hand-written fakes (most idiomatic) — define a small interface in the consumer package and pass a struct that implements it

  • gomock / mockgen — if the repo has //go:generate mockgen ... directives or mocks/ directories, regenerate via go generate ./... rather than editing generated files

  • testify/mock — used in many repos; instantiate with new(MockX) and chain .On("Method", ...).Return(...)

  • httptest — for HTTP clients/servers; spin up httptest.NewServer instead of mocking http.Client

Always prefer dependency injection over global function patching. If a test needs more than 3 mocks, flag it as a design smell.

Concurrency and Cleanup

  • Use t.Cleanup(func() { ... }) instead of deferring in test bodies — runs even if t.FailNow fires

  • Use t.TempDir() for temp files — auto-cleaned at test end

  • Use t.Context() (Go 1.24+) or pass an explicit context.Background() — never call real network or filesystem APIs without one in long-running tests

Dependency Installation (Last Resort)

Only install packages after investigation confirms they are missing:

go get github.com/stretchr/testify@latest
go mod tidy

Run go mod tidy after any go get to keep go.sum consistent. Never edit go.sum by hand.

Skip Coverage Tools

Do not configure or run coverage tools (-cover, -coverprofile, go tool cover). Coverage is measured separately by the evaluation harness.

Requirements and compatibility

Written for: Claude Code

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Claude Code frontmatter, Needs Python

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
.NET (Microsoft)
Publisher
.NET (Microsoft) (Official)
Source
dotnet/skills · plugins/dotnet-test/skills/code-testing-extensions · commit 96c3d68
Licence
MIT License (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by .NET (Microsoft) or .NET (Microsoft).

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download code-testing-extensions.zip