Code Testing Extensions
.NET (Microsoft)OfficialPublished by .NET (Microsoft)
- Skill
- Guidelines
- Software development
- MIT
- Low risk
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
Download the skill as a ZIP:
https://autogineer.com/agent-skills/dotnet/code-testing-extensions/downloadUnzip 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
| File | Language | Contents |
|---|---|---|
| extensions/dotnet.md | .NET (C#/F#/VB) | Build commands, test commands, project reference validation, common CS error codes, MSTest template |
| extensions/python.md | Python | Framework-adaptive test commands (pytest, custom runners), project layout detection, mocking guidelines, common errors |
| extensions/typescript.md | TypeScript/JavaScript | Build/test commands (Jest/Vitest/Mocha), framework detection, mocking, TS-specific considerations |
| extensions/powershell.md | PowerShell | Test commands (Pester v5), module import patterns, discovery/run pitfalls, mocking, common errors |
| extensions/cpp.md | C++ | Testing internals with friend declarations |
| extensions/go.md | Go | go test commands, table-driven tests, integration vs unit layout, mocking via interfaces, common errors |
| extensions/java.md | Java | Maven/Gradle commands, JUnit 4/5 and TestNG detection, Mockito, Spring Boot slices, common errors |
| extensions/rust.md | Rust | cargo test commands, unit vs integration vs doc tests, features, async test harnesses, common errors |
| extensions/ruby.md | Ruby | RSpec and Minitest commands, Bundler usage, Rails specifics, mocking patterns, common errors |
| extensions/swift.md | Swift | SPM and Xcode test commands, XCTest vs Swift Testing, @testable import, async/throws tests, common errors |
| extensions/kotlin.md | Kotlin | Gradle 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.md | Python | Concrete pipeline examples (pytest): research, plan, generated test file, fix cycles, final report |
| extensions/typescript-examples.md | TypeScript/JavaScript | Concrete pipeline examples (Vitest, applicable to Jest): research, plan, generated test file, fix cycles, final report |
| extensions/go-examples.md | Go | Concrete pipeline examples (standard testing): research, plan, table-driven test file, fix cycles, final report |
| extensions/java-examples.md | Java | Concrete 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
- ATTRIBUTION.mdAdded by AutoGineer857 B
- LICENSELicence file added by AutoGineer1.1 KiB
- SKILL.md3.7 KiB
- extensions/cpp-examples.md9.1 KiB
- extensions/cpp.md20.1 KiB
- extensions/dotnet-examples.md10.7 KiB
- extensions/dotnet.md10.5 KiB
- extensions/go-examples.md12.4 KiB
- extensions/go.md7.8 KiB
- extensions/java-examples.md11.9 KiB
- extensions/java.md9.7 KiB
- extensions/kotlin-examples.md10.3 KiB
- extensions/kotlin.md11.2 KiB
- extensions/powershell-examples.md9.1 KiB
- extensions/powershell.md12.1 KiB
- extensions/python-examples.md12.1 KiB
- extensions/python.md11.7 KiB
- extensions/ruby-examples.md8.9 KiB
- extensions/ruby.md14.7 KiB
- extensions/rust-examples.md10.6 KiB
- extensions/rust.md8.8 KiB
- extensions/swift.md9.4 KiB
- extensions/typescript-examples.md12.7 KiB
- extensions/typescript.md7.9 KiB
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:
Existing tests — look at
#[cfg(test)] mod testsblocks insidesrc/, integration tests intests/, doc tests in source comments, and anyexamples/that double as smoke testsCargo.toml— workspace layout ([workspace]), edition,dev-dependencies, feature flags,[[bench]]/[[test]]declarationsCargo.lock— if checked in, you must not break it without intentToolchain —
rust-toolchain.tomlpins the channel (stable / nightly / specific version)build.rs— custom build scripts may setcfgflags 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
| Indicator | Meaning |
|---|---|
rust-toolchain.toml with channel = "..." | Use rustup to install/select that channel — rustup show active-toolchain |
rust-version = "1.x" in Cargo.toml | Minimum supported Rust version (MSRV); do not use newer language features |
[workspace] in root Cargo.toml | Multi-crate workspace; commands accept -p <crate> to target one member |
nightly channel | Tests may use #![feature(...)] flags; do not remove them |
Build Commands
| Scope | Command |
|---|---|
| Type-check fast | cargo check |
| Type-check whole workspace | cargo check --workspace --all-targets |
| Build (debug) | cargo build |
| Build with all features | cargo build --all-features |
| Build a single crate | cargo build -p crate-name |
| Build tests without running | cargo 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
| Scope | Command |
|---|---|
| All tests | cargo test |
| Workspace | cargo test --workspace |
| Single crate | cargo test -p crate-name |
| Filter by name | cargo test substring_of_test_name |
| Exact name | cargo test -- --exact path::to::test_fn |
| Single integration file | cargo test --test file_stem (no .rs) |
| Doc tests only | cargo test --doc |
| Show stdout | cargo test -- --nocapture |
| Single-threaded | cargo test -- --test-threads=1 |
| Ignored tests | cargo test -- --ignored |
| With features | cargo test --features "feat1 feat2" |
| All features | cargo test --all-features |
Arguments before
--are for cargo; arguments after--go to the test binarycargo test fooruns every test withfooin its full path (module::tests::foo_does_a_thing) — to avoid surprise matches use--exactcargo nextest runis 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 warningsIf
clippy.toml/rustfmt.tomlexists, 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 type | Where | Sees |
|---|---|---|
| Unit test | #[cfg(test)] mod tests inside the source file | Private items in the surrounding module |
| Integration test | tests/<name>.rs | Only the public API of the crate |
| Doc test | /// doctests in source comments | Only 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(themod.rsform prevents cargo from treating them as a top-level test crate)
Test Function Patterns
| Kind | Attribute |
|---|---|
| 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 Result | fn 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
| Error | Fix |
|---|---|
cannot find type X in this scope | Add 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 satisfied | Either implement the trait, add a where bound, or change the test to use a type that already implements it |
borrow of moved value | Add .clone(), borrow with &, or restructure ownership — do not use mem::transmute to dodge it |
cannot borrow as mutable | Make the binding let mut x or restructure to avoid simultaneous mutable + immutable borrows |
lifetime may not live long enough | Add explicit lifetime annotations or use owned types (String instead of &str) in the test |
mismatched types between i32 and usize | Use as casts deliberately or change the literal type with a suffix (5usize, 5u32) |
unresolved import 'crate::...' in tests/foo.rs | Integration tests must import via the crate name (as listed in Cargo.toml), not crate:: |
error: no test target found for cargo test --test foo | The 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 compile | Use 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 genericT: Trait, implement a fake struct in testsmockallcrate:#[automock]on a trait generatesMockTraitfor use in testsmockito/wiremock: HTTP server mocks for client teststempfile: 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 themod testsor individual#[test]functions--all-featuresexercises everything but may pull conflicting features in some workspaces; checkcargo test --all-featuresis part of CI before relying on itUse
#[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_testcrate (if present) or move state into the testNever write to
/tmpor the repo dir directly — usetempfile::tempdir()so cleanup is automaticTests in
unsafecode 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-threadMatch 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