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

.NET Extension

Language-specific guidance for .NET (C#/F#/VB) test generation.

Project System Detection

Determine the project system before choosing any command or editing a manifest.

SignalProject systemConsequence
Root <Project Sdk="..."> or an Sdk attributeSDK-styledotnet build / dotnet test are normally valid; new *.cs files are usually included by glob
ToolsVersion, Microsoft.Common.props / Microsoft.CSharp.targets imports, explicit <Reference> and <Compile Include> itemsClassic non-SDKPreserve the repository's MSBuild / test-runner commands; every new source or test file must be added to the project
packages.config beside the projectClassic NuGet dependency managementPreserve packages.config and assembly references; do not run dotnet add package or introduce PackageReference unless the user explicitly requested a migration

For classic projects, inspect repository scripts, CI configuration, README*, and AGENTS.md for the authoritative build and test commands. Common commands are MSBuild.exe followed by vstest.console.exe or MSTest.exe, but the checked-in command wins. If no compatible runner is installed, report that blocker instead of migrating the project or claiming dotnet test succeeded.

Build Commands

ScopeCommand
SDK-style test projectdotnet build MyProject.Tests.csproj
SDK-style solution (final validation)dotnet build MySolution.sln --no-incremental
Classic non-SDK projectUse the repository's existing MSBuild command (often MSBuild.exe MySolution.sln /t:Build)
  • Use --no-restore if dependencies are already restored

  • Use -v:q (quiet) to reduce output noise

  • Always use --no-incremental for the final validation build — incremental builds hide errors like CS7036

Test Commands

ScopeCommand
SDK-style all testsdotnet test
SDK-style filtereddotnet test --filter "FullyQualifiedName~ClassName"
SDK-style after builddotnet test --no-build
Classic non-SDKUse the checked-in runner command; commonly vstest.console.exe <test.dll> after MSBuild
  • Use --no-build if already built

  • Use -v:q for quieter output

Lint Command

dotnet format --include path/to/file.cs
dotnet format MySolution.sln         # full solution

Project Reference Validation

Before writing test code, read the test project's .csproj to verify it has <ProjectReference> entries for the assemblies your tests will use. If a reference is missing, add it:

<ItemGroup>
    <ProjectReference Include="../SourceProject/SourceProject.csproj" />
</ItemGroup>

This prevents CS0234 ("namespace not found") and CS0246 ("type not found") errors. In a classic project, preserve its existing <ProjectReference> metadata and configuration mappings instead of replacing them with the SDK-style shorthand.

Common CS Error Codes

ErrorMeaningFix
CS0234Namespace not foundAdd <ProjectReference> to the source project in the test .csproj
CS0246Type not foundAdd using Namespace; or add missing <ProjectReference>
CS0103Name not foundCheck spelling, add using statement
CS1061Missing memberVerify method/property name matches the source code exactly
CS0029Type mismatchCast or change the type to match the expected signature
CS7036Missing required parameterRead the constructor/method signature and pass all required arguments

.csproj / .sln Handling

  • During phase implementation, build only the specific test .csproj for speed

  • For the final validation, build the full .sln with --no-incremental

  • Full-solution builds catch cross-project reference errors invisible in scoped builds

Registering test code with the build (MANDATORY)

Before writing a new C# test file, inspect the test project's compile items.

  • SDK-style projects normally include *.cs by glob. Do not add a redundant <Compile Include> unless default compile items are disabled.

  • Classic non-SDK projects require an explicit item for every new file. Add a path relative to the project, preserving its path separator and ordering:

<Compile Include="Services\OrderServiceTests.cs" />

After editing, re-open the project and verify the exact new test path appears once. A file on disk that is missing from a classic project's compile items is not part of the test assembly and must never be reported as generated coverage.

Registering a new test project (MANDATORY when dotnet new was used)

A new .csproj is invisible to dotnet test <solution>, to dotnet test run from the repo root, and to any CI/benchmark harness until it is added to the solution. Run dotnet sln add immediately after creating the project as part of Step 3 ("Register Test Project with Build System") — do not defer it to a later step.

  1. Use the exact solution or solution-filter target identified in the research or plan document under <TESTAGENT_DIR> — do not search for or substitute a different .sln, .slnx, or .slnf target.

  2. If that target is a .sln or .slnx, run dotnet sln <solution> add <test-project.csproj>.

  3. If the target is a .slnf (solution filter), also ensure the new project is included in the filter; adding only to the underlying .sln may not be enough for test discovery.

  4. Skip this if the project is already included in the solution or solution filter used for testing.

  5. Prefer the researched test command. If you need to run the solution directly, use dotnet test --solution <solution> only for repos on .NET SDK 10+ with MTP-style syntax; otherwise use the standard positional form dotnet test <solution>.

Harness Discovery Check

Before reporting success, run the harness-equivalent discovery command from the repo root against the exact researched entry point and confirm it enumerates the new tests. Passing a project directly does not prove that the solution/filter command used by CI discovers it.

Select the command mode from the repository's actual runner configuration, global.json test.runner, evaluated project properties, and installed SDK using platform-detection. An SDK 10+ installation alone does not select native MTP.

Command mode / executed runnerDiscovery command after a successful build
VSTest mode / VSTestdotnet test <solution> --list-tests --no-build
VSTest mode / bridged MTPdotnet test <solution> --no-build -- --list-tests
SDK 10+ native MTP mode / MTPdotnet test --solution <solution> --list-tests --no-build

Preserve the repository's configuration, target framework, and filtering switches. For project entry points, use --project <test-project> in native MTP mode and the positional project in VSTest mode.

Run discovery directly and require exit code zero before inspecting its output or runner-owned discovery artifact. Do not pipe it into grep -c, wc, or a counting command that hides the runner's exit status. Compare test identities and counts using the actual runner format; MTP output need not have VSTest's indentation. Where a count is meaningful, compare the same command before and after and require the expected delta.

If tests are missing, inspect registration, filters, compile items, and runner configuration before repairing the proven missing edge. A zero delta alone does not prove a project is absent. Do not report success until the harness command sees your new tests.

For a classic non-SDK project, use the repository's normal build and discovery command instead of the example above. The minimum acceptable check is:

  1. the new file is present exactly once as <Compile Include="...">;

  2. the classic project builds with its documented MSBuild command; and

  3. the repository's test runner discovers the new test(s).

If the environment lacks the required Visual Studio/MSBuild/test-runner toolchain, verify item registration, report that execution is blocked, and do not substitute dotnet test or modernize the project.

Test Framework Detection

Detect the framework and installed version from the test project's .csproj, packages.config, and referenced assembly HintPath values. Match the existing framework, mocking library, base fixtures, and API level:

Package ReferenceFrameworkAttributesAssertion Style
MSTest.Sdk or MSTest.TestFrameworkMSTest[TestClass], [TestMethod], [DataRow]Assert.AreEqual(expected, actual)
xunitxUnit[Fact], [Theory], [InlineData]Assert.Equal(expected, actual)
NUnitNUnit[TestFixture], [Test], [TestCase]Assert.That(actual, Is.EqualTo(expected))

Use the repo's existing framework — do not introduce a different one.

For MSTest, load writing-mstest-tests only for APIs supported by the installed version. In particular, Assert.ThrowsExactly and the unified collection assertions require MSTest 3.8+, while older suites should keep compatible Assert.ThrowsException, StringAssert, and CollectionAssert patterns. Never upgrade MSTest, Moq, NBuilder, or another test dependency merely to use a newer example.

MSTest Template

using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace ProjectName.Tests;

[TestClass]
public sealed class ClassNameTests
{
    [TestMethod]
    public void MethodName_Scenario_ExpectedResult()
    {
        // Arrange
        var sut = new ClassName();

        // Act
        var result = sut.MethodName(input);

        // Assert
        Assert.AreEqual(expected, result);
    }

    [TestMethod]
    [DataRow(2, 3, 5, DisplayName = "Positive numbers")]
    [DataRow(-1, 1, 0, DisplayName = "Negative and positive")]
    public void Add_ValidInputs_ReturnsSum(int a, int b, int expected)
    {
        // Act
        var result = _sut.Add(a, b);

        // Assert
        Assert.AreEqual(expected, result);
    }
}

Skip Coverage Tools

Do not configure or run code coverage measurement tools (coverlet, dotnet-coverage, XPlat Code Coverage) by default. These tools have inconsistent cross-configuration behavior and waste significant time. Coverage is measured separately by the evaluation harness.

SDK-style exception: if the user or evaluation harness explicitly requires a Cobertura/XML artifact, add coverlet.collector as a PackageReference so the harness can produce it. For classic non-SDK projects, preserve packages.config and use only the repository's existing coverage workflow; never inject a PackageReference. Do not run the coverage command yourself.

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