Migrate GetCharactersPageUseCaseTest to runTest and add kotlinx-coroutines-test dependency to domain module.

This commit is contained in:
2026-06-11 10:47:08 +02:00
parent f6f81991a8
commit 9ae6e5935a
2 changed files with 7 additions and 5 deletions

View File

@@ -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))