testing-flows-with-turbine

Assert Kotlin Flow emissions in unit tests using Turbine.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires app.cash.turbine:turbine.

What problem does it solve?

This skill resolves the common issue where testing Kotlin Flows, particularly hot flows like StateFlow or SharedFlow, causes tests to hang indefinitely because they never complete.

Core Features & Use Cases

  • Safe Flow Assertion: Provides a robust API to assert Flow emissions one-by-one without risking test timeouts.
  • Hot Flow Handling: Specifically designed to manage the lifecycle of hot flows, ensuring they are properly cancelled during test teardown.
  • Multi-Flow Coordination: Enables complex testing scenarios where multiple flows must be observed and asserted concurrently.

Quick Start

Use the testing-flows-with-turbine skill to assert the emissions of the uiState flow in your ViewModel test.

Frequently Asked Questions about testing-flows-with-turbine

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

FAQPage Schema
Why does my Kotlin Flow test hang indefinitely when collecting emissions?

Testing hot flows like StateFlow or SharedFlow causes hangs because they never complete. Turbine prevents these hangs by safely managing flow cancellation and lifecycle during test teardown.

How do I assert StateFlow or SharedFlow emissions without test timeouts?

To assert StateFlow or SharedFlow emissions without test timeouts, use the Turbine library to collect and verify values one-by-one within a Coroutine TestScope that controls virtual time.

Can I test multiple Kotlin Flows concurrently in the same unit test?

Yes, you can test multiple flows concurrently. Turbine supports complex multi-flow coordination scenarios, enabling you to observe and assert emissions from several flows simultaneously.

Does Turbine work with both cold flows and hot flows in JVM environments?

Yes, Turbine works with both cold flows and hot flows in JVM or Android environments. It integrates with Coroutine TestScope to manage virtual time and handle flow collection safely.

What is the best way to assert Flow emissions one-by-one in unit tests?

The best way to assert Flow emissions one-by-one is using Turbine's robust API, which safely verifies sequential emissions and handles hot flow cancellation to prevent test hangs.