Skip to content

Commit cde3455

Browse files
authored
Disabled parallel mode. It's too unstable and fails builds. (#348)
1 parent ed15982 commit cde3455

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

Diff for: architecture/presentation-test/src/main/java/com/mitteloupe/whoami/architecture/presentation/viewmodel/BaseViewModelTest.kt

+7-5
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import com.mitteloupe.whoami.architecture.domain.exception.DomainException
55
import com.mitteloupe.whoami.architecture.domain.usecase.UseCase
66
import com.mitteloupe.whoami.architecture.presentation.notification.PresentationNotification
77
import com.mitteloupe.whoami.coroutine.currentValue
8-
import kotlinx.coroutines.DelicateCoroutinesApi
98
import kotlinx.coroutines.Dispatchers
109
import kotlinx.coroutines.ExperimentalCoroutinesApi
11-
import kotlinx.coroutines.newSingleThreadContext
1210
import kotlinx.coroutines.runBlocking
11+
import kotlinx.coroutines.test.TestCoroutineScheduler
12+
import kotlinx.coroutines.test.UnconfinedTestDispatcher
1313
import kotlinx.coroutines.test.resetMain
1414
import kotlinx.coroutines.test.setMain
1515
import org.junit.After
@@ -28,8 +28,10 @@ abstract class BaseViewModelTest<
2828
NOTIFICATION : PresentationNotification,
2929
VIEW_MODEL : BaseViewModel<VIEW_STATE, NOTIFICATION>
3030
> {
31-
@OptIn(DelicateCoroutinesApi::class, ExperimentalCoroutinesApi::class)
32-
private val mainThreadSurrogate = newSingleThreadContext("UI thread")
31+
private val testScheduler = TestCoroutineScheduler()
32+
33+
@OptIn(ExperimentalCoroutinesApi::class)
34+
private val testDispatcher = UnconfinedTestDispatcher(testScheduler)
3335

3436
protected lateinit var classUnderTest: VIEW_MODEL
3537

@@ -41,7 +43,7 @@ abstract class BaseViewModelTest<
4143
@OptIn(ExperimentalCoroutinesApi::class)
4244
@Before
4345
fun coroutineSetUp() {
44-
Dispatchers.setMain(mainThreadSurrogate)
46+
Dispatchers.setMain(testDispatcher)
4547
}
4648

4749
@OptIn(ExperimentalCoroutinesApi::class)

Diff for: architecture/ui/src/main/java/com/mitteloupe/whoami/architecture/ui/view/BaseComposeHolder.kt

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ abstract class BaseComposeHolder<VIEW_STATE : Any, NOTIFICATION : PresentationNo
1717
private val navigationMapper: NavigationEventDestinationMapper<PresentationNavigationEvent>,
1818
private val notificationMapper: NotificationUiMapper
1919
) {
20-
2120
@Composable
2221
fun ViewModelObserver(navController: NavController) {
2322
val navigation = viewModel.navigationEvent.collectAsState(

Diff for: gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
1010
# When configured, Gradle will run in incubating parallel mode.
1111
# This option should only be used with decoupled projects. More details, visit
1212
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
13-
org.gradle.parallel=true
13+
org.gradle.parallel=false
1414
org.gradle.caching=true
1515
# AndroidX package structure to make it clearer which packages are bundled with the
1616
# Android operating system, and which are packaged with your app's APK

Diff for: home/presentation/src/test/java/com/mitteloupe/whoami/home/presentation/viewmodel/HomeViewModelTest.kt

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import com.mitteloupe.whoami.home.presentation.navigation.HomePresentationNaviga
1818
import kotlinx.coroutines.CoroutineStart.UNDISPATCHED
1919
import kotlinx.coroutines.async
2020
import kotlinx.coroutines.flow.first
21-
import kotlinx.coroutines.runBlocking
2221
import kotlinx.coroutines.test.runTest
2322
import org.junit.Assert.assertEquals
2423
import org.junit.Before
@@ -64,7 +63,7 @@ class HomeViewModelTest :
6463
}
6564

6665
@Test
67-
fun `Given disconnected when onEnter then presents disconnected state`() = runBlocking {
66+
fun `Given disconnected when onEnter then presents disconnected state`() = runTest {
6867
// Given
6968
val givenConnectionState = Disconnected
7069
givenSuccessfulUseCaseExecution(

0 commit comments

Comments
 (0)