From 06c290bdfb74a8a6212e407fdd9e7406bae71ff8 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Fri, 3 Nov 2023 15:05:47 +0900 Subject: [PATCH] :rotating_light: Add opt in annotations & rearrange dependencies --- frontend/app/build.gradle.kts | 10 +++++----- .../com/example/speechbuddy/SignupViewModelTest.kt | 4 ++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/app/build.gradle.kts b/frontend/app/build.gradle.kts index c04bcce8..a737ef29 100644 --- a/frontend/app/build.gradle.kts +++ b/frontend/app/build.gradle.kts @@ -62,6 +62,7 @@ dependencies { implementation("androidx.compose.ui:ui-tooling-preview") implementation("androidx.compose.material3:material3") testImplementation("junit:junit:4.13.2") + testImplementation("androidx.arch.core:core-testing:2.2.0") androidTestImplementation("androidx.test.ext:junit:1.1.5") androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1") androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00")) @@ -83,6 +84,7 @@ dependencies { val coroutinesVersion = "1.7.1" implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion") implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") // Preference implementation("androidx.preference:preference-ktx:1.2.1") @@ -119,10 +121,8 @@ dependencies { implementation("androidx.hilt:hilt-navigation-compose:1.0.0") - // Test + // MockK val mockkVersion = "1.13.8" - testImplementation ("io.mockk:mockk-android:$mockkVersion") - testImplementation ("io.mockk:mockk-agent:$mockkVersion") - testImplementation ("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion") - testImplementation ("androidx.arch.core:core-testing:2.1.0") + testImplementation("io.mockk:mockk-agent:$mockkVersion") + testImplementation("io.mockk:mockk-android:$mockkVersion") } \ No newline at end of file diff --git a/frontend/app/src/test/java/com/example/speechbuddy/SignupViewModelTest.kt b/frontend/app/src/test/java/com/example/speechbuddy/SignupViewModelTest.kt index d22f2b08..76c7ff56 100644 --- a/frontend/app/src/test/java/com/example/speechbuddy/SignupViewModelTest.kt +++ b/frontend/app/src/test/java/com/example/speechbuddy/SignupViewModelTest.kt @@ -10,6 +10,7 @@ import io.mockk.coEvery import io.mockk.impl.annotations.MockK import io.mockk.mockk import junit.framework.TestCase.assertEquals +import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.flowOf @@ -23,6 +24,8 @@ import org.junit.Rule import org.junit.Test class SignupViewModelTest { + + @OptIn(DelicateCoroutinesApi::class) private val mainThreadSurrogate = newSingleThreadContext("UI thread") @MockK @@ -50,6 +53,7 @@ class SignupViewModelTest { viewModel = SignupViewModel(repository) } + @OptIn(ExperimentalCoroutinesApi::class) @After fun tearDown() { Dispatchers.resetMain()