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://mp-staging.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/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:
Existing tests — find files in
Tests/(SPM) or*Tests/groups (Xcode) and copy their style. Distinguish XCTest (import XCTest, classes inheritingXCTestCase) from Swift Testing (import Testing, free functions tagged@Test)Project file —
Package.swift(SPM),*.xcodeproj,*.xcworkspace, orProject.swift(Tuist)Swift toolchain —
.swift-version,swift-tools-versionline inPackage.swift,IPHONEOS_DEPLOYMENT_TARGETandSWIFT_VERSIONbuild settings in XcodeCI 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
| Indicator | Project type | Build tool |
|---|---|---|
Package.swift only | Swift Package Manager | swift build / swift test |
*.xcodeproj or *.xcworkspace | Xcode project (often app/iOS) | xcodebuild |
| Both | SPM library + Xcode app shell | Use SPM for library targets, Xcode for app targets |
Project.swift (Tuist) | Tuist-generated Xcode project | Run tuist generate first, then xcodebuild |
project.yml (XcodeGen) | XcodeGen-generated project | Run 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
| Scope | Command |
|---|---|
| Build all | swift build |
| Build a target | swift build --target MyLibrary |
| Build for release | swift build -c release |
Xcode (xcodebuild)
xcodebuild build \
-workspace MyApp.xcworkspace \
-scheme MyAppScheme \
-destination 'platform=iOS Simulator,name=iPhone 15' \
-configuration DebugAlways specify
-destinationfor iOS/tvOS/watchOS — the default may not exist on the build machineUse
-quietto suppress xcodebuild's chatty output, and pipe toxcbeautify/xcprettyif installedFor deterministic CI builds add
-derivedDataPath ./DerivedData
Test Commands
Swift Package Manager
| Scope | Command |
|---|---|
| All tests | swift test |
| Filter by test name (XCTest) | swift test --filter MyClassTests/testFooBar |
| Filter by test name (Swift Testing) | swift test --filter MyTestSuite.fooBar |
| Parallel | swift test --parallel |
| Single platform | swift 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:acceptBundle/Class/Methodpaths and may be repeatedxcodebuild test-without-buildingskips compilation if you've already builtFor 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.ymlis presentswiftformat .when.swiftformatis presentSome projects gate format on a build phase — running
xcodebuildmay already invoke it
Project Layout
SPM
Package.swift
Sources/
└── MyLibrary/
├── Foo.swift
└── Bar.swift
Tests/
└── MyLibraryTests/
└── FooTests.swiftTest target name conventionally is
<TargetName>Testsand lives inTests/<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" actionThe 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 XCTestplus@testable import MyLibraryto accessinternalsymbolsSwift Testing:
import Testingplus@testable import MyLibrary@testableworks 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
publicsolely to make it visible to tests — use@testable importinstead
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
testand take no argumentsMark XCTest classes
finalto silence warnings and prevent unintended subclassingUse
XCTUnwrapinstead of force-unwrapping (!) inside tests so the failure is reported rather than crashing the runner
Async, Throws, and Concurrency
Test methods may be
asyncand/orthrowsin both frameworksFor asynchronous expectations under XCTest, use
XCTestExpectation+wait(for:timeout:)only when you cannot refactor toasyncFor Swift Testing, use
await confirmation { ... }to assert that a callback firesCancel tasks deliberately with
Task.cancel()instead of relying on test timeout
Common Errors
| Error | Fix |
|---|---|
cannot find 'X' in scope from a test | Add @testable import MyLibrary (and ensure the test target depends on it) |
module 'MyLibrary' was not compiled for testing | Build 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 target | XCTest 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 tests | Often a force-unwrap on nil; replace ! with XCTUnwrap to localize the failure |
MainActor-isolated property cannot be referenced from a non-isolated context | Mark the test method @MainActor or move setup into a MainActor task |
Sandbox: ... deny file-write-create | Use FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString) instead of writing to fixed paths |
| Test discovery shows zero tests on Linux | XCTest 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
URLProtocolsubclasses to interceptURLSessionrequests, or useMockingbirdSwift/Cuckooif the repo already adopts themFor dates/clocks, inject a
Clock(ContinuousClock,SuspendingClock, or a customClock-conforming type) — do not callDate()directly in business logicAvoid
swizzlingand 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 necessaryUse
String(decoding:as:)rather thanString(contentsOf:encoding:)for cross-platform readsBe careful with
Bundle.mainin tests — on macOS unit tests it points toxctest, not your bundle; useBundle(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