Skip to content

Instantly share code, notes, and snippets.

@kaszabimre
Created June 21, 2023 09:30
Show Gist options
  • Save kaszabimre/15831c21b04927537b61009f5b01a2d9 to your computer and use it in GitHub Desktop.
Save kaszabimre/15831c21b04927537b61009f5b01a2d9 to your computer and use it in GitHub Desktop.
Unit test for the GitHubUserListViewModel class showcasing the simplicity of using MockKMP framework. The test sets up mock objects for GitHubUserAction and GitHubUserStore, both of which are interfaces. The GitHubUserListViewModel is instantiated using the mock dependencies, demonstrating the ease of integration with MockKMP.
class GitHubUserListViewModelTest : TestsWithMocks() {
@Mock
lateinit var action: GitHubUserAction
@Mock
lateinit var store: GitHubUserStore
private val viewModel by withMocks { GitHubUserListViewModel(action, store) }
override fun setUpMocks() = injectMocks(mocker)
....
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment