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

Swift Extension

Language-specific guidance for Swift test generation.

Rule #1: Investigate the Repo First

Before writing any test or running any command, read:

  1. Existing tests — find files in Tests/ (SPM) or *Tests/ groups (Xcode) and copy their style. Distinguish XCTest (import XCTest, classes inheriting XCTestCase) from Swift Testing (import Testing, free functions tagged @Test)

  2. Project file — Package.swift (SPM), *.xcodeproj, *.xcworkspace, or Project.swift (Tuist)

  3. Swift toolchain — .swift-version, swift-tools-version line in Package.swift, IPHONEOS_DEPLOYMENT_TARGET and SWIFT_VERSION build settings in Xcode

  4. CI scripts — .github/workflows/*.yml, Fastfile, Makefile — these reveal the canonical build/test invocation

Use the testing framework the repo already uses. Both XCTest and Swift Testing can coexist in one target — match what the file you're adding tests next to uses.

Project Type Detection

IndicatorProject typeBuild tool
Package.swift onlySwift Package Managerswift build / swift test
*.xcodeproj or *.xcworkspaceXcode project (often app/iOS)xcodebuild
BothSPM library + Xcode app shellUse SPM for library targets, Xcode for app targets
Project.swift (Tuist)Tuist-generated Xcode projectRun tuist generate first, then xcodebuild
project.yml (XcodeGen)XcodeGen-generated projectRun xcodegen generate first

If both an .xcodeproj and .xcworkspace exist (e.g. CocoaPods), always pass -workspace not -project to xcodebuild.

Build Commands

Swift Package Manager
ScopeCommand
Build allswift build
Build a targetswift build --target MyLibrary
Build for releaseswift build -c release
Xcode (xcodebuild)
xcodebuild build \
  -workspace MyApp.xcworkspace \
  -scheme MyAppScheme \
  -destination 'platform=iOS Simulator,name=iPhone 15' \
  -configuration Debug
  • Always specify -destination for iOS/tvOS/watchOS — the default may not exist on the build machine

  • Use -quiet to suppress xcodebuild's chatty output, and pipe to xcbeautify/xcpretty if installed

  • For deterministic CI builds add -derivedDataPath ./DerivedData

Test Commands

Swift Package Manager
ScopeCommand
All testsswift test
Filter by test name (XCTest)swift test --filter MyClassTests/testFooBar
Filter by test name (Swift Testing)swift test --filter MyTestSuite.fooBar
Parallelswift test --parallel
Single platformswift test --triple x86_64-apple-macosx (rare; usually skip)
Xcode
xcodebuild test \
  -workspace MyApp.xcworkspace \
  -scheme MyAppScheme \
  -destination 'platform=iOS Simulator,name=iPhone 15' \
  -only-testing:MyAppTests/MyClassTests/testFooBar
  • -only-testing: and -skip-testing: accept Bundle/Class/Method paths and may be repeated

  • xcodebuild test-without-building skips compilation if you've already built

  • For Swift Testing in Xcode 16+, use the same -only-testing: syntax — the runner handles both frameworks

Lint Command

Use the repo's lint tooling first:

  • swiftlint lint --quiet (autocorrect: swiftlint --fix) when .swiftlint.yml is present

  • swiftformat . when .swiftformat is present

  • Some projects gate format on a build phase — running xcodebuild may already invoke it

Project Layout

SPM
Package.swift
Sources/
└── MyLibrary/
    ├── Foo.swift
    └── Bar.swift
Tests/
└── MyLibraryTests/
    └── FooTests.swift
  • Test target name conventionally is <TargetName>Tests and lives in Tests/<TargetName>Tests/

  • Test target must list its production target as a dependency in Package.swift:

    .testTarget(
        name: "MyLibraryTests",
        dependencies: ["MyLibrary"]),
Xcode
  • Tests live in a separate target (e.g. MyAppTests) added to the scheme's "Test" action

  • The test target's "Host Application" determines whether tests run on the simulator with the app loaded (unit tests) or as a UI test runner

Imports

  • XCTest: import XCTest plus @testable import MyLibrary to access internal symbols

  • Swift Testing: import Testing plus @testable import MyLibrary

  • @testable works only when the production target is built with -enable-testing (the SPM test target and Xcode "Debug" config do this by default)

  • Never mark production code public solely to make it visible to tests — use @testable import instead

Test File Templates

Swift Testing (Xcode 16 / Swift 6)
import Testing
@testable import MyLibrary

@Suite("Calculator")
struct CalculatorTests {
    @Test("add returns the sum of two integers")
    func addReturnsSum() {
        let calc = Calculator()
        #expect(calc.add(2, 3) == 5)
    }

    @Test("add throws on overflow", arguments: [
        (Int.max, 1),
        (Int.min, -1),
    ])
    func addThrowsOnOverflow(a: Int, b: Int) {
        #expect(throws: ArithmeticError.self) {
            try Calculator().add(a, b)
        }
    }
}
XCTest
import XCTest
@testable import MyLibrary

final class CalculatorTests: XCTestCase {
    func testAddReturnsSum() {
        let calc = Calculator()
        XCTAssertEqual(calc.add(2, 3), 5)
    }

    func testAddThrowsOnOverflow() {
        XCTAssertThrowsError(try Calculator().add(.max, 1)) { error in
            XCTAssertEqual(error as? ArithmeticError, .overflow)
        }
    }
}
  • XCTest requires test methods to start with test and take no arguments

  • Mark XCTest classes final to silence warnings and prevent unintended subclassing

  • Use XCTUnwrap instead of force-unwrapping (!) inside tests so the failure is reported rather than crashing the runner

Async, Throws, and Concurrency

  • Test methods may be async and/or throws in both frameworks

  • For asynchronous expectations under XCTest, use XCTestExpectation + wait(for:timeout:) only when you cannot refactor to async

  • For Swift Testing, use await confirmation { ... } to assert that a callback fires

  • Cancel tasks deliberately with Task.cancel() instead of relying on test timeout

Common Errors

ErrorFix
cannot find 'X' in scope from a testAdd @testable import MyLibrary (and ensure the test target depends on it)
module 'MyLibrary' was not compiled for testingBuild the production target with -enable-testing; SPM test targets do this automatically — Xcode Debug configs need "Enable Testability" = YES
failed to launch test runner (Xcode)Simulator destination may be invalid; list with xcrun simctl list devices and pick an existing one
No such module 'XCTest' outside a test targetXCTest is only available in test targets — do not import it from production code
Static method 'expect(_:_:sourceLocation:)' is unavailable / No such module 'Testing'Swift Testing requires Swift 6 / Xcode 16+. On older toolchains, fall back to XCTest
Symbol not found: _OBJC_CLASS_$_...Linker missing a framework; add it to the test target's "Link Binary With Libraries"
signal SIGABRT in testsOften a force-unwrap on nil; replace ! with XCTUnwrap to localize the failure
MainActor-isolated property cannot be referenced from a non-isolated contextMark the test method @MainActor or move setup into a MainActor task
Sandbox: ... deny file-write-createUse FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) instead of writing to fixed paths
Test discovery shows zero tests on LinuxXCTest on Linux needs XCTMain([testCase(MyTests.allTests), ...]) in Tests/LinuxMain.swift (legacy SwiftPM only); for Swift 5.4+ this is auto-generated

Mocking Rules

Swift has no Mockito-equivalent — favor protocol-oriented design:

  • Define a protocol for the dependency, pass it via initializer, and implement a fake/stub struct in the test target

  • For URL/HTTP, use URLProtocol subclasses to intercept URLSession requests, or use MockingbirdSwift / Cuckoo if the repo already adopts them

  • For dates/clocks, inject a Clock (ContinuousClock, SuspendingClock, or a custom Clock-conforming type) — do not call Date() directly in business logic

  • Avoid swizzling and runtime hacks — they break under Swift's optimizer

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

Cross-Platform Considerations

  • Swift on Linux supports XCTest but not all of Foundation — guard with #if canImport(Darwin) or #if os(macOS) only when necessary

  • Use String(decoding:as:) rather than String(contentsOf:encoding:) for cross-platform reads

  • Be careful with Bundle.main in tests — on macOS unit tests it points to xctest, not your bundle; use Bundle(for: type(of: self)) (XCTest) or a resource-bundle helper

Dependency Installation (Last Resort)

Only add dependencies after investigation confirms they are missing.

Package.swift:

.package(url: "https://github.com/apple/swift-collections.git", from: "1.1.0"),

Then add to the test target's dependencies:. For CocoaPods/Carthage, edit Podfile/Cartfile and run pod install / carthage update --use-xcframeworks.

Skip Coverage Tools

Do not configure or run coverage tools (-enableCodeCoverage YES, xccov, slather). 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