writing-tests-with-kotlin-test

Standardize test assertions and lifecycle annotations across Kotlin Multiplatform projects.

Updated Jul 20, 2026
One-click install
npx skills add https://github.com/trancee/MeshLink-template --skill writing-tests-with-kotlin-test-trancee
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-tests-with-kotlin-test
Source: https://github.com/trancee/MeshLink-template/tree/main/.agents/skills/android-testing-skills/kotlin/kotlin-test/writing-tests-with-kotlin-test
Command: npx skills add https://github.com/trancee/MeshLink-template --skill writing-tests-with-kotlin-test-trancee

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill solves the fragmentation of testing frameworks across Kotlin Multiplatform targets by providing a single, engine-agnostic assertion and annotation API that works seamlessly in commonTest, JVM, Android, JS, and Native environments.

Core Features & Use Cases

  • Unified API: Provides a consistent set of assert functions like assertEquals, assertFailsWith, and assertIs that behave identically across all Kotlin targets.
  • Framework Agnostic: Automatically maps annotations like @Test and @BeforeTest to the underlying test runner (JUnit4, JUnit5, or native runners) without requiring platform-specific imports.
  • Use Case: When developing a shared library, use this skill to write a single test suite that validates business logic in commonTest, ensuring identical behavior when executed on both Android instrumentation and JVM unit tests.

Quick Start

Use the writing-tests-with-kotlin-test skill to refactor my existing JUnit4 imports to kotlin.test equivalents and verify the test suite runs across all multiplatform targets.

Frequently Asked Questions about writing-tests-with-kotlin-test

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write unified tests for a Kotlin Multiplatform project?

To write unified Kotlin Multiplatform tests, use the kotlin.test library to standardize assertions and lifecycle annotations across commonTest, JVM, Android, JS, and Native targets. This provides a single, engine-agnostic API for your shared test source sets.

How do I migrate JUnit assertions to kotlin.test in shared source sets?

Migrate JUnit assertions to kotlin.test by replacing platform-specific imports with unified equivalents like assertEquals and assertFailsWith. This refactoring ensures your test suite runs identically across all multiplatform targets without requiring platform-specific dependencies.

Does kotlin.test work with JUnit4 and JUnit5 runners?

Yes, kotlin.test works with JUnit4 and JUnit5 runners by automatically mapping annotations like @Test and @BeforeTest to the underlying test runner. This framework-agnostic approach requires no platform-specific imports while maintaining engine compatibility.

What is the benefit of using kotlin.test over platform-specific testing frameworks?

The benefit of using kotlin.test over platform-specific frameworks is cross-target compatibility and compile-time type safety via @OnlyInputTypes. It eliminates testing fragmentation by providing consistent assert functions that behave identically across JVM, JS, and Native environments.

Can I use assertFailsWith and assertIs in Kotlin Multiplatform commonTest?

Yes, you can use assertFailsWith and assertIs in Kotlin Multiplatform commonTest. The kotlin.test library provides these consistent assertion functions to validate exceptions and types seamlessly across JVM, Android, JS, and Native environments.