Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android Model-View-Intent with Unit Tests - FeedViewTest.kt Bind Interface
private lateinit var test: FeedViewTestCase
private val intent = FeedViewIntent()
@ParameterizedTest
@MethodSource("FeedViewTestCaseStream")
fun `FeedView`(feedViewTestCase: FeedViewTestCase) = testCoroutineDispatcher.runBlockingTest {
test = feedViewTestCase
mockComponents(test)
val viewModel = FeedViewModel(...)
viewModel.bindIntents(object : FeedView {
override fun initState() = intent.initState
override fun loadFromNetwork() = intent.loadFromNetwork.filterNotNull()
override fun render(state: FeedViewState) {
when (state) {
is Feed -> testRenderFeed(state)
...
}
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment