writing-tests-with-kotlin-test

Write multiplatform Kotlin tests using kotlin.test assertions across JVM, Android, JS, Native, and Wasm.

303|10|Updated May 15, 2026
One-click install
npx skills add https://github.com/skydoves/android-testing-skills --skill writing-tests-with-kotlin-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: writing-tests-with-kotlin-test
Source: https://github.com/skydoves/android-testing-skills/tree/main/kotlin/kotlin-test/writing-tests-with-kotlin-test
Command: npx skills add https://github.com/skydoves/android-testing-skills --skill writing-tests-with-kotlin-test

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It solves the problem of writing portable Kotlin tests by giving you a single, multiplatform-compatible set of annotations and assertion functions that work the same across JVM, Android, JS, Native, and Wasm without tying your code to JUnit APIs.

Core Features & Use Cases

  • Framework-agnostic test annotations: Use @Test, @Ignore, @BeforeTest, and @AfterTest, which typealias to the active test framework on each platform (e.g., JUnit4 vs JUnit5).
  • Portable assertions: Use assertEquals/assertNotEquals, identity checks (assertSame), null checks (assertNull/assertNotNull), type checks (assertIs/assertIsNot), and collection/value helpers like assertContentEquals, assertContains, plus fail, expect, and exception assertions (assertFails, assertFailsWith).
  • Safety and quality guardrails: Leverages @OnlyInputTypes to make type mismatches fail at compile time, not at runtime, and supports the Asserter extension point to control failure rendering.

Quick Start

Use this skill when you need to write multiplatform tests by importing kotlin.test symbols (such as kotlin.test.*, @BeforeTest, and assertFailsWith) and keeping your test source engine-agnostic.

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 Kotlin multiplatform tests that run consistently across JVM, Android, JS, Native, and Wasm?

To write Kotlin multiplatform tests consistently, use the kotlin.test assertion and annotation API in commonTest to avoid direct org.junit imports and ensure tests run on the appropriate runner adapter per target.

What is the best way to assert typed exceptions in commonTest without tying code to JUnit?

The best way to assert typed exceptions in commonTest is using the kotlin.test API's assertFailsWith<E> function, which enables typed exception assertions while remaining framework-agnostic across all Kotlin multiplatform targets.

Can I use JUnit annotations like @Test and @BeforeTest in Kotlin multiplatform testing?

Yes, you can use framework-agnostic test annotations like @Test, @BeforeTest, and @AfterTest from kotlin.test, which typealias to the active test framework on each platform, such as JUnit4 or JUnit5.

Does kotlin.test support compile-time type safety for assertion mismatches?

Yes, kotlin.test supports compile-time type safety for assertion mismatches by leveraging the @OnlyInputTypes annotation, ensuring that type mismatches fail at compile time rather than at runtime during test execution.

How do I customize failure rendering when using kotlin.test assertions in multiplatform projects?

To customize failure rendering in kotlin.test, use the Asserter extension point to control failure reporting, allowing you to tailor the output behavior across JVM, Android, JS, Native, and Wasm targets.