kp-testing-coroutines
Installation
SKILL.md
One-line summary
Use runTest { … } + a TestDispatcher for fast, deterministic tests of coroutine code — virtual time replaces real delay, and dispatcher injection makes your production code testable without runBlocking.
When to use this skill
- Writing unit tests for
suspend funorFlow. - Testing time-dependent behavior (timeouts, delays, debounce, sample) without real waiting.
- Testing concurrent coroutines and their interactions.
- Replacing slow / flaky
runBlockingtest setups.
When NOT to use this skill
- The code isn't actually suspending and no coroutines are involved — use a regular test.
- Integration tests that genuinely need real time and threads —
runBlockingmay still be appropriate (rarely).
Core content
runTest { … } is the canonical entry point from kotlinx-coroutines-test. It runs your test body as a coroutine with a TestScope that has a TestDispatcher and a virtual clock.