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://mp-staging.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/java.md

Java Extension

Language-specific guidance for Java test generation.

Rule #1: Investigate the Repo First

Before writing any test or running any command, read:

  1. Existing tests — find *Test.java / *Tests.java / *IT.java (integration) files and copy their style (JUnit version, assertion library, mock library, lifecycle methods)

  2. Build file — pom.xml (Maven), build.gradle / build.gradle.kts (Gradle), BUILD / BUILD.bazel (Bazel)

  3. Java version — <maven.compiler.release>, sourceCompatibility, or toolchains block

  4. Wrapper scripts — always prefer ./mvnw or ./gradlew over a system-installed Maven/Gradle so you match the project's pinned version

Use whatever framework the repo already uses (JUnit 4, JUnit 5/Jupiter, TestNG). Do not migrate to a different framework as a side effect of writing tests.

Build Tool Detection

IndicatorBuild toolDefault test command
pom.xmlMaven./mvnw test
build.gradle / build.gradle.ktsGradle./gradlew test
settings.gradle* with include 'subproject'Gradle multi-project./gradlew :subproject:test
BUILD / BUILD.bazelBazelbazel test //path/to:test

If both pom.xml and build.gradle exist, pick the one used by CI.

Build Commands

ScopeMavenGradle
Compile main + test./mvnw test-compile./gradlew testClasses
Compile only./mvnw compile./gradlew classes
Full build./mvnw verify./gradlew build
Skip tests during build./mvnw -DskipTests package./gradlew assemble
  • Use -q (Maven) / --console=plain (Gradle) to reduce output noise

  • For Gradle, prefer --no-daemon only in CI; locally the daemon makes incremental builds far faster

Test Commands

ScopeMavenGradle
All unit tests./mvnw test./gradlew test
Single class./mvnw test -Dtest=MyClassTest./gradlew test --tests MyClassTest
Single method./mvnw test -Dtest=MyClassTest#myMethod./gradlew test --tests MyClassTest.myMethod
Tag filter (JUnit 5)./mvnw test -Dgroups=fast./gradlew test -PincludeTags=fast (if configured) or --tests
Integration tests./mvnw verify -DskipUnitTests (with failsafe-plugin)./gradlew integrationTest (if registered)
  • Surefire runs unit tests (*Test.java); Failsafe runs integration tests (*IT.java) — do not put long integration tests under Surefire

  • Gradle's --tests accepts wildcards: --tests "*MyMethod*"

  • Use --rerun-tasks (Gradle) or -DforkCount=... (Surefire) only when troubleshooting cache issues

Lint Command

Use the repo's existing lint task first. Otherwise check for:

  • Checkstyle (checkstyle.xml, <plugin>checkstyle</plugin>) → ./mvnw checkstyle:check or ./gradlew checkstyleMain

  • Spotless (spotless block / plugin) → ./mvnw spotless:apply or ./gradlew spotlessApply

  • ErrorProne / NullAway → integrated into compilation; run a normal build

  • google-java-format / palantir-java-format → use the repo's configured formatter

Never disable existing checks in the test files you generate.

Project Layout and Imports

Maven/Gradle conventional layout:

src/
├── main/java/com/example/foo/Bar.java
├── main/resources/
├── test/java/com/example/foo/BarTest.java
└── test/resources/
LayoutTest placement
Standardsrc/test/java/<same package as production class>/<ClassName>Test.java
Integration tests separatedsrc/integrationTest/java/... (Gradle) or src/it/java/... (Maven w/ failsafe)
Multi-module MavenTests live in the same module as the code under test
  • Test classes must mirror the production class's package to access package-private members

  • Avoid wildcard imports unless the repo already uses them — match the explicit imports shown in the templates below

  • For JUnit 5: import org.junit.jupiter.api.Test (and other annotations as needed) and org.junit.jupiter.api.Assertions.assertEquals etc. as static imports

  • For JUnit 4: import org.junit.Test, org.junit.Before, etc., and org.junit.Assert.assertEquals etc. as static imports

Test Framework Detection

IndicatorFrameworkAnnotationsAssertion style
junit-jupiter-* depsJUnit 5@Test, @ParameterizedTest, @BeforeEach, @DisplayNameAssertions.assertEquals(expected, actual)
junit:junit:4.xJUnit 4@Test, @Before, @RunWithAssert.assertEquals(expected, actual)
org.testng:testngTestNG@Test(groups=...), @BeforeMethodAssert.assertEquals(actual, expected) (note reversed order)
org.assertj:assertj-coreAssertJ (assertions only)n/aassertThat(actual).isEqualTo(expected)
org.hamcrest:hamcrestHamcrest matchersn/aassertThat(actual, is(equalTo(expected)))

Argument order matters: JUnit/AssertJ use (expected, actual); TestNG uses (actual, expected). Reversing them produces confusing failure messages.

JUnit 5 Template

package com.example.foo;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

class CalculatorTest {

    @Test
    @DisplayName("add returns sum of two positive numbers")
    void add_positiveNumbers_returnsSum() {
        Calculator sut = new Calculator();
        assertEquals(5, sut.add(2, 3));
    }

    @ParameterizedTest
    @CsvSource({
        "2, 3, 5",
        "-1, 1, 0"
    })
    void add_validInputs_returnsSum(int a, int b, int expected) {
        assertEquals(expected, new Calculator().add(a, b));
    }

    @Test
    void divide_byZero_throws() {
        Calculator sut = new Calculator();
        assertThrows(ArithmeticException.class, () -> sut.divide(1, 0));
    }
}

Common Errors

ErrorFix
package X does not existAdd the dependency to pom.xml / build.gradle; run ./mvnw dependency:resolve or ./gradlew --refresh-dependencies
cannot find symbolVerify class name and import path; check that the test source set sees the production source set
No tests found for given includes (Gradle)--tests pattern doesn't match; verify the class/method names, that test methods are annotated with @Test, and that the class name matches the test task's include pattern (default **/*Test*.class). For JUnit 4 only, the class must also be public with a public no-arg constructor — JUnit 5 allows package-private classes and methods
Test class should have exactly one public zero-argument constructor (JUnit 4)Remove constructors with parameters; use @Before for setup
org.junit.runners.model.InvalidTestClassError (JUnit 4)Class is missing public, has wrong constructor, or method signature is wrong
Mixing org.junit.Test (4) and org.junit.jupiter.api.Test (5)Pick one framework per test class — imports must match the framework annotation
java.lang.NoClassDefFoundError at runtimeTest runtime classpath is missing a transitive dep; add it to testRuntimeOnly (Gradle) or <scope>test</scope> (Maven)
UnsupportedClassVersionErrorJDK used to run tests is older than the JDK used to compile; align toolchains
Mockito cannot mock final classUse Mockito's inline mock maker — Mockito 5+ uses it by default; for Mockito 3.x/4.x add the mockito-inline artifact (replaces mockito-core). Or switch to MockK for Kotlin. mockito-subclass does not mock final classes
WrongTypeOfReturnValue (Mockito)The stubbed method returns a different type than the mock was set up for — check return type signatures

Mocking Rules

  • Use whatever the repo already uses: Mockito (most common), EasyMock, JMockit, or hand-written fakes

  • For JUnit 5 + Mockito, use @ExtendWith(MockitoExtension.class) with @Mock / @InjectMocks fields

  • For JUnit 4 + Mockito, use @RunWith(MockitoJUnitRunner.class) or MockitoAnnotations.openMocks(this) in @Before

  • Use when(mock.method(...)).thenReturn(...) for stubs and verify(mock).method(...) for interactions

  • Use ArgumentCaptor to assert on complex argument values rather than over-specifying matchers

  • Prefer constructor injection so production code stays testable without @InjectMocks

  • If a test needs more than 3 mocks, flag it as a design smell

Spring Boot

If the repo uses Spring Boot:

  • @SpringBootTest loads the full context — slow; use only when needed

  • Slice tests are faster: @WebMvcTest, @DataJpaTest, @JsonTest

  • Use @MockBean (Spring) only inside Spring tests; in plain unit tests use @Mock

  • Use @Testcontainers for real-DB integration tests if the repo already has it on the classpath

Dependency Installation (Last Resort)

Only add dependencies after investigation confirms they are missing.

Maven (pom.xml):

<dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>5.10.2</version>
    <scope>test</scope>
</dependency>

Gradle (build.gradle.kts):

testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

If the repo uses BOMs (<dependencyManagement> or Gradle platforms), reuse them — don't pin a different version than the BOM publishes.

Skip Coverage Tools

Do not configure or run coverage tools (JaCoCo, Cobertura, OpenClover). 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).

Download ZIP

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