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/kotlin.md
Kotlin Extension
Language-specific guidance for Kotlin test generation. For pure-Java codebases, use java.md instead.
Rule #1: Investigate the Repo First
Before writing any test or running any command, read:
Existing tests — find files in
src/test/kotlin/,src/commonTest/kotlin/,src/jvmTest/kotlin/, etc., and copy their style (framework, assertion library, mock library, coroutine helpers)Build file —
build.gradle.kts/build.gradle— note Kotlin version, plugins (kotlin("jvm"),kotlin("multiplatform"),kotlin("android")), anddependencies { testImplementation(...) }gradle/libs.versions.toml— the version catalog if the repo uses one; reference aliases instead of hard-coded versionsWrapper script — always invoke
./gradlew(Unix) or.\gradlew.bat(Windows), never a system-installed GradleMultiplatform layout —
src/<sourceSet>/kotlin/indicates KMP; tests live in matching*Testsource sets (commonTest,jvmTest,nativeTest)
Use whatever framework the repo already uses (JUnit Jupiter, JUnit 4, Kotest, kotlin.test). Do not switch.
Project Type Detection
| Indicator | Project type |
|---|---|
kotlin("jvm") plugin | Plain JVM Kotlin |
kotlin("multiplatform") plugin with kotlin { jvm(); js(); ... } | Kotlin Multiplatform |
com.android.application / com.android.library plugin | Android |
org.springframework.boot plugin | Spring Boot Kotlin |
kotlin("jvm") + application plugin | Kotlin CLI / server |
For Android, see also platform-specific test types: src/test/ for unit tests on the JVM, src/androidTest/ for instrumented tests on a device/emulator. They use different runners and gradle tasks.
Build Commands
| Scope | Command |
|---|---|
| Compile main + test (JVM) | ./gradlew compileTestKotlin |
| Full build | ./gradlew build |
| Skip tests | ./gradlew assemble |
| Single module | ./gradlew :module-name:build |
| KMP target only | ./gradlew :module:jvmTest (or linuxX64Test, etc.) |
Use
--console=plainto suppress Gradle's animated outputUse
--build-cache(often default in CI) to reuse outputsFor Android:
./gradlew assembleDebug(build APK) and./gradlew testDebugUnitTest(run unit tests)
Test Commands
| Scope | Command |
|---|---|
| All tests (JVM) | ./gradlew test |
| Single class | ./gradlew test --tests "com.example.WidgetTest" |
| Single method | ./gradlew test --tests "com.example.WidgetTest.add returns sum" |
| KMP all targets | ./gradlew allTests |
| KMP one target | ./gradlew jvmTest, ./gradlew jsTest, ./gradlew linuxX64Test |
| Android unit tests | ./gradlew testDebugUnitTest |
| Android instrumented | ./gradlew connectedDebugAndroidTest (requires device/emulator) |
--testsaccepts wildcards:--tests "*Widget*". Method names with spaces or backticks must be quoted:--tests "com.example.WidgetTest.creates a widget"Use
--rerun-tasksonly when troubleshooting cache issuesFor Kotest, the runner is registered with JUnit Platform — the standard
./gradlew testand--testsflags work the same way
Lint Command
Use the repo's lint tooling first:
./gradlew ktlintCheck(autoformat:./gradlew ktlintFormat) when ktlint is configured./gradlew detektwhen detekt is configured./gradlew spotlessCheck/spotlessApplyfor the Spotless pluginAndroid Studio's IDE inspections;
./gradlew lint(Android-only) for the Android Lint task
Project Layout
src/
├── main/kotlin/com/example/foo/Bar.kt
├── main/resources/
├── test/kotlin/com/example/foo/BarTest.kt # mirrors production package
└── test/resources/KMP layout:
src/
├── commonMain/kotlin/... # shared
├── commonTest/kotlin/... # shared tests using kotlin.test
├── jvmMain/kotlin/...
├── jvmTest/kotlin/...
├── jsMain/kotlin/...
└── jsTest/kotlin/...Test classes mirror the production class's package so they can access
internalmembers (Kotlin'sinternalis module-scoped — within the same Gradle module, including the test source set)For KMP common tests, you can only import from
kotlin.testand other multiplatform-aware libraries (e.g.kotlinx.coroutines.test, Kotest multiplatform, MockK on JVM only)
Test Framework Detection
| Dependency | Framework | Annotations / DSL |
|---|---|---|
org.jetbrains.kotlin:kotlin-test | kotlin.test (multiplatform) | @Test, @BeforeTest, assertEquals, assertFailsWith |
junit-jupiter-* | JUnit 5 | @Test, @ParameterizedTest, @BeforeEach, @DisplayName |
junit:junit:4.x | JUnit 4 | @Test, @Before, @RunWith(JUnitPlatform::class) rare |
io.kotest:kotest-runner-junit5 | Kotest | class FooSpec : FunSpec({ test("...") { ... } }) (DSL — many styles: StringSpec, BehaviorSpec, etc.) |
org.spekframework.spek2:spek-dsl-jvm | Spek 2 | object FooSpec : Spek({ describe(...) { it(...) {} } }) (legacy) |
For Kotest, stick to the spec style the repo already uses — mixing styles is confusing.
Test Templates
JUnit 5
package com.example.foo
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import kotlin.test.assertEquals
class CalculatorTest {
@Test
@DisplayName("add returns sum of two positive numbers")
fun `add returns sum of two positives`() {
val sut = Calculator()
assertEquals(5, sut.add(2, 3))
}
@Test
fun `divide by zero throws`() {
val sut = Calculator()
assertThrows<ArithmeticException> { sut.divide(1, 0) }
}
}Backticked method names (`like this`) are idiomatic for Kotlin tests because they read better in failure messages.
Kotest (StringSpec)
package com.example.foo
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.assertions.throwables.shouldThrow
class CalculatorSpec : StringSpec({
"add returns sum of two positive numbers" {
Calculator().add(2, 3) shouldBe 5
}
"divide by zero throws" {
shouldThrow<ArithmeticException> { Calculator().divide(1, 0) }
}
})Coroutines
Use
kotlinx-coroutines-testwhen it's already on the classpath; otherwise add it as atestImplementationonly after confirming it is missing (see Dependency Installation)Use
runTest { ... }(replaces the olderrunBlockingTest) forsuspendtest bodiesFor virtual time advance, use a
TestDispatcherbuilt fromtestScheduler— e.g.StandardTestDispatcher(testScheduler)orUnconfinedTestDispatcher(testScheduler)— rather than callingdelayand waiting in real timeInject a
CoroutineDispatcherinto production code instead of usingDispatchers.Main/IOdirectly — then swap it in tests viaDispatchers.setMain(testDispatcher)
@Test
fun `loads data eventually`() = runTest {
val repo = FakeRepo()
val dispatcher = StandardTestDispatcher(testScheduler)
val sut = Loader(repo, dispatcher)
sut.start()
advanceUntilIdle()
assertEquals(LoadState.Done, sut.state.value)
}Common Errors
| Error | Fix |
|---|---|
Unresolved reference: X | Add the import; verify the test source set sees the production source set; for KMP, the dep may be declared only in jvmTest |
Cannot access 'X': it is internal in module Y | internal is module-scoped, so a test in another Gradle module cannot see it. Move the test into the same module, expose a public seam (e.g. a *-testing artifact, or change visibility deliberately), or add the consuming module to the source module's friend modules via the Kotlin compiler -Xfriend-paths option. @VisibleForTesting does not widen Kotlin visibility |
Class 'XTest' is not abstract and does not implement abstract member (Kotest spec) | The spec class needs a no-arg constructor and a primary-constructor block — match the existing spec style |
No tests found for given includes (Gradle) | --tests pattern doesn't match; verify class name and that the framework's runner is registered on the test task (useJUnitPlatform()) |
kotlin.UninitializedPropertyAccessException: lateinit property X has not been initialized | The @BeforeEach (or BeforeTest) didn't run, or the field was reset; use lateinit only after confirming the lifecycle hook fires |
IllegalStateException: Module with the Main dispatcher had failed to initialize | Coroutines test needs Dispatchers.setMain(...) before launching anything that touches Dispatchers.Main; reset with Dispatchers.resetMain() in teardown |
Mockito cannot mock final class | Kotlin classes are final by default — either use MockK (works with final classes) or apply the kotlin-allopen plugin scoped to a marker annotation |
MissingMockKException | The mock wasn't initialized; call MockKAnnotations.init(this) or use @MockK with @MockKExtension (JUnit 5) |
| KMP common test references a JVM-only API | Move the test to jvmTest, or use expect/actual declarations |
Android: Method ... not mocked | The unit test runs on the JVM and the SDK class is just a stub — either use Robolectric, move the test to instrumented (androidTest), or refactor to inject the dependency |
Mocking Rules
MockK is the de-facto standard for Kotlin (final classes, coroutine support):
every { mock.foo() } returns 1,coEvery { mock.suspendFn() } returns 1,verify { mock.foo() },coVerify { ... }Mockito works on Kotlin too with
mockito-kotlinextensions, but Kotlin classes arefinalby default — use Mockito's inline mock maker (default in Mockito 5+; themockito-inlineartifact for Mockito 3.x/4.x).mockito-subclasscannot mock final classesAvoid
mockkStatic/mockkObjectfor production code you control — refactor to a wrapper insteadPrefer constructor injection so you don't need framework annotations (
@InjectMocks) at allIf a test needs more than 3 mocks, flag it as a design smell
Android Specifics
Robolectric tests live under
src/test/and emulate the Android framework on the JVM — fast but imperfectInstrumented tests live under
src/androidTest/, require a connected device/emulator, and are slow — use sparinglyCompose UI tests use
createComposeRule()andcomposeTestRule.onNodeWithText(...).performClick()— match the existing test setup if Compose is in the projectHilt: use
@HiltAndroidTestandHiltAndroidRulefor instrumented tests; for unit tests pass fakes directly to ViewModels
Dependency Installation (Last Resort)
Only add dependencies after investigation confirms they are missing.
build.gradle.kts:
dependencies {
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2")
testImplementation("io.mockk:mockk:1.13.10")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0")
}
tasks.test {
useJUnitPlatform()
}If the repo uses a version catalog, add to gradle/libs.versions.toml and reference via libs.junit.jupiter etc. Match the major versions already in use.
Skip Coverage Tools
Do not configure or run coverage tools (JaCoCo, Kover). 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