Created
January 27, 2023 15:00
-
-
Save alexzaitsev/dd734a601304ca6b4b4e6dccd54e2e80 to your computer and use it in GitHub Desktop.
Dummy test to demonstrate Flow testing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.domain.usecase | |
import app.cash.turbine.test | |
import com.natpryce.hamkrest.assertion.assertThat | |
import com.natpryce.hamkrest.equalTo | |
import kotlinx.coroutines.flow.flowOf | |
import kotlinx.coroutines.test.runTest | |
import org.junit.Test | |
class DummyTest { | |
class UseCase { | |
operator fun invoke(input: String) = flowOf(input) | |
} | |
fun produceSut() = UseCase() | |
@Test | |
fun `invoke() emits data with correct attribute anyPendingTxs true`() = runTest { | |
// arrange mocks, create sut | |
val sut = produceSut() | |
// act | |
val result = sut("input") | |
// assert | |
result.test { | |
assertThat(awaitItem(), equalTo("input")) | |
awaitComplete() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment