# The conflation problem of testing StateFlows

DevFeed: [The conflation problem of testing StateFlows](<https://devfeed.tech/articles/the-conflation-problem-of-testing-stateflows-27057.md>)

Original publisher: [Read original article](<https://zsmb.co/conflating-stateflows/>)

Author: Márton Braun

Published: 2023-08-15T14:00:00Z

Content type: tutorial

Language: en

Sources: [zsmb.co](<https://devfeed.tech/sources/zsmb-co.md>)

Topics: [Testing](<https://devfeed.tech/topics/testing.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [coroutine-testing](<https://devfeed.tech/tags/coroutine-testing.md>), [coroutines](<https://devfeed.tech/tags/coroutines.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlinx](<https://devfeed.tech/tags/kotlinx.md>), [marton-braun](<https://devfeed.tech/tags/marton-braun.md>), [stateflow](<https://devfeed.tech/tags/stateflow.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>), [ui](<https://devfeed.tech/tags/ui.md>), [viewmodel](<https://devfeed.tech/tags/viewmodel.md>), [zsmb](<https://devfeed.tech/tags/zsmb.md>), [zsmb-co](<https://devfeed.tech/tags/zsmb-co.md>), [zsmb13](<https://devfeed.tech/tags/zsmb13.md>), [zsmbco](<https://devfeed.tech/tags/zsmbco.md>)

## AI overview

This article explains how StateFlow conflation affects tests. It compares asserting on the StateFlow state property with collecting emitted values, and discusses testing intermediate values when rapid updates may be skipped by slow collectors.

## Source excerpt

StateFlow behaves as a state holder and a Flow of values at the same time. Due to conflation, a collector of a StateFlow might not receive all values that it holds over time. This article covers what that means for your tests.