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/rust.md

Rust Extension

Language-specific guidance for Rust test generation.

Rule #1: Investigate the Repo First

Before writing any test or running any command, read:

  1. Existing tests — look at #[cfg(test)] mod tests blocks inside src/, integration tests in tests/, doc tests in source comments, and any examples/ that double as smoke tests

  2. Cargo.toml — workspace layout ([workspace]), edition, dev-dependencies, feature flags, [[bench]] / [[test]] declarations

  3. Cargo.lock — if checked in, you must not break it without intent

  4. Toolchain — rust-toolchain.toml pins the channel (stable / nightly / specific version)

  5. build.rs — custom build scripts may set cfg flags or generate code that tests rely on

Match the repo's existing conventions — assertion macros, mock approach, feature-gating — exactly. Do not introduce tokio::test if the repo uses async-std, etc.

Toolchain Detection

IndicatorMeaning
rust-toolchain.toml with channel = "..."Use rustup to install/select that channel — rustup show active-toolchain
rust-version = "1.x" in Cargo.tomlMinimum supported Rust version (MSRV); do not use newer language features
[workspace] in root Cargo.tomlMulti-crate workspace; commands accept -p <crate> to target one member
nightly channelTests may use #![feature(...)] flags; do not remove them

Build Commands

ScopeCommand
Type-check fastcargo check
Type-check whole workspacecargo check --workspace --all-targets
Build (debug)cargo build
Build with all featurescargo build --all-features
Build a single cratecargo build -p crate-name
Build tests without runningcargo test --no-run

cargo check is far faster than cargo build and catches almost the same errors. Prefer it during the fix loop; use cargo build --tests (or cargo test --no-run) before declaring tests compilable.

Test Commands

ScopeCommand
All testscargo test
Workspacecargo test --workspace
Single cratecargo test -p crate-name
Filter by namecargo test substring_of_test_name
Exact namecargo test -- --exact path::to::test_fn
Single integration filecargo test --test file_stem (no .rs)
Doc tests onlycargo test --doc
Show stdoutcargo test -- --nocapture
Single-threadedcargo test -- --test-threads=1
Ignored testscargo test -- --ignored
With featurescargo test --features "feat1 feat2"
All featurescargo test --all-features
  • Arguments before -- are for cargo; arguments after -- go to the test binary

  • cargo test foo runs every test with foo in its full path (module::tests::foo_does_a_thing) — to avoid surprise matches use --exact

  • cargo nextest run is significantly faster if the repo already uses it (Cargo.toml [profile.nextest...] or .config/nextest.toml) — match the repo's choice

Lint Command

Use the repo's lint script first. Otherwise:

  • cargo fmt --all -- --check (CI), cargo fmt (apply)

  • cargo clippy --all-targets --all-features -- -D warnings

  • If clippy.toml / rustfmt.toml exists, the project has opinions — never override them in your tests

Project Layout

my_crate/
├── Cargo.toml
├── src/
│   ├── lib.rs        # library crate root
│   ├── main.rs       # binary crate root (mutually OK with lib.rs)
│   └── module.rs     # private/public module
├── tests/            # integration tests — each .rs is a separate crate
│   └── widget.rs
├── benches/          # cargo bench targets
└── examples/         # cargo run --example name
Test typeWhereSees
Unit test#[cfg(test)] mod tests inside the source filePrivate items in the surrounding module
Integration testtests/<name>.rsOnly the public API of the crate
Doc test/// doctests in source commentsOnly the public API; runs via cargo test --doc
  • Unit tests at the bottom of module.rs:

    #[cfg(test)]
    mod tests {
        use super::*;
    
        #[test]
        fn name_scenario_expected() {
            // ...
        }
    }
  • Integration tests import the crate by name: use my_crate::PublicType;

  • Helpers shared between integration tests must live in tests/common/mod.rs (the mod.rs form prevents cargo from treating them as a top-level test crate)

Test Function Patterns

KindAttribute
Sync test#[test]
Should panic#[test] #[should_panic(expected = "message substring")]
Ignored (long/manual)#[test] #[ignore = "reason"]
Async test (Tokio)#[tokio::test] (or #[tokio::test(flavor = "multi_thread")])
Async test (async-std)#[async_std::test]
Returning Resultfn name() -> Result<(), Box<dyn Error>> — use ? instead of .unwrap()

Pick the async harness the repo already uses. Do not mix tokio and async-std in tests.

Common Errors

ErrorFix
cannot find type X in this scopeAdd use crate::module::X; or use super::*; inside the test module
function or associated item not found in 'X'Verify the method exists on the exact type; check trait imports (e.g. use std::io::Read)
the trait bound 'X: Y' is not satisfiedEither implement the trait, add a where bound, or change the test to use a type that already implements it
borrow of moved valueAdd .clone(), borrow with &, or restructure ownership — do not use mem::transmute to dodge it
cannot borrow as mutableMake the binding let mut x or restructure to avoid simultaneous mutable + immutable borrows
lifetime may not live long enoughAdd explicit lifetime annotations or use owned types (String instead of &str) in the test
mismatched types between i32 and usizeUse as casts deliberately or change the literal type with a suffix (5usize, 5u32)
unresolved import 'crate::...' in tests/foo.rsIntegration tests must import via the crate name (as listed in Cargo.toml), not crate::
error: no test target found for cargo test --test fooThe file must live directly in tests/, not tests/subdir/foo.rs (subdirs are treated as helpers)
attempt to subtract with overflow (debug)Underflow on unsigned types; use checked_sub/saturating_sub or compare before subtracting
Doctest fails to compileUse a leading "# " on hidden setup lines; mark code blocks ignore/no_run/should_panic if needed
the following imports are unused (warning treated as error)Remove unused use statements; do not silence with #[allow(unused_imports)]

Mocking Rules

Rust has no single dominant mocking framework. Match the repo:

  • Trait + struct fakes (most idiomatic): define a trait, pass Arc<dyn Trait> or generic T: Trait, implement a fake struct in tests

  • mockall crate: #[automock] on a trait generates MockTrait for use in tests

  • mockito / wiremock: HTTP server mocks for client tests

  • tempfile: scoped temp directories that auto-clean (tempfile::tempdir())

Avoid unsafe patches to "mock" free functions. Refactor to inject a trait instead. If a test needs more than 3 mocks, flag it as a design smell.

Features and cfg

  • Tests behind a feature flag run only when that feature is enabled — use #[cfg(feature = "foo")] on the mod tests or individual #[test] functions

  • --all-features exercises everything but may pull conflicting features in some workspaces; check cargo test --all-features is part of CI before relying on it

  • Use #[cfg(test)] to gate test-only helpers in production source files — not #[cfg(feature = "test")]

Concurrency, IO, and unsafe

  • Tests run in parallel by default. If your tests share global state (env vars, current dir, statics), serialize them with the serial_test crate (if present) or move state into the test

  • Never write to /tmp or the repo dir directly — use tempfile::tempdir() so cleanup is automatic

  • Tests in unsafe code should also run under Miri (cargo +nightly miri test) if the repo's CI does

Dependency Installation (Last Resort)

Only add dependencies after investigation confirms they are missing:

[dev-dependencies]
mockall = "0.12"
tokio = { version = "1", features = ["macros", "rt-multi-thread"] }

Or via cargo:

cargo add --dev mockall
cargo add --dev tokio --features macros,rt-multi-thread

Match the major version of any tokio/serde/etc. already pinned by the workspace.

Skip Coverage Tools

Do not configure or run coverage tools (cargo tarpaulin, cargo llvm-cov, grcov). 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