Migrate GetCharactersPageUseCaseTest to runTest and add kotlinx-coroutines-test dependency to domain module.
This commit is contained in:
@@ -12,7 +12,7 @@ import com.example.architecture.feature.characters.domain.model.CharactersPage
|
||||
import io.mockk.coEvery
|
||||
import io.mockk.coVerify
|
||||
import io.mockk.mockk
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import org.junit.jupiter.api.Test
|
||||
|
||||
/**
|
||||
@@ -27,7 +27,7 @@ class GetCharactersPageUseCaseTest {
|
||||
private val useCase = GetCharactersPageUseCase(repository)
|
||||
|
||||
@Test
|
||||
fun `returns the repository page on success`() = runBlocking {
|
||||
fun `returns the repository page on success`() = runTest {
|
||||
val page = CharactersPage(characters = listOf(domainCharacter(1)), nextPage = 2)
|
||||
coEvery { repository.getCharacters(1) } returns Result.Success(page)
|
||||
|
||||
@@ -37,7 +37,7 @@ class GetCharactersPageUseCaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `propagates the repository error`() = runBlocking {
|
||||
fun `propagates the repository error`() = runTest {
|
||||
coEvery { repository.getCharacters(1) } returns Result.Error(DataError.Network.SERVER_ERROR)
|
||||
|
||||
val result = useCase(page = 1)
|
||||
@@ -47,7 +47,7 @@ class GetCharactersPageUseCaseTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `forwards the requested page number`() = runBlocking {
|
||||
fun `forwards the requested page number`() = runTest {
|
||||
coEvery { repository.getCharacters(any()) } returns
|
||||
Result.Success(CharactersPage(characters = emptyList(), nextPage = null))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user