Skip to content

Commit

Permalink
added CoroutineTestRule()
Browse files Browse the repository at this point in the history
Signed-off-by: Basler182 <[email protected]>
  • Loading branch information
Basler182 authored and eldcn committed Jul 1, 2024
1 parent e56c0a5 commit b7ec2db
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.firebase.auth.FirebaseAuth
import com.google.firebase.auth.FirebaseUser
import edu.stanford.bdh.engagehf.navigation.AppNavigationEvent
import edu.stanford.spezi.core.navigation.Navigator
import edu.stanford.spezi.core.testing.CoroutineTestRule
import edu.stanford.spezi.core.testing.runTestUnconfined
import edu.stanford.spezi.module.account.AccountEvents
import edu.stanford.spezi.module.onboarding.OnboardingNavigationEvent
Expand All @@ -13,17 +14,18 @@ import io.mockk.coVerify
import io.mockk.every
import io.mockk.mockk
import io.mockk.slot
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.test.UnconfinedTestDispatcher
import kotlinx.coroutines.test.setMain
import org.junit.Before
import org.junit.Rule
import org.junit.Test

@ExperimentalCoroutinesApi
class MainActivityViewModelTest {

@get:Rule
val coroutineTestRule = CoroutineTestRule()

private lateinit var viewModel: MainActivityViewModel
private val accountEvents: AccountEvents = mockk(relaxed = true)
private val navigator: Navigator = mockk(relaxed = true)
Expand All @@ -33,7 +35,6 @@ class MainActivityViewModelTest {

@Before
fun setUp() {
Dispatchers.setMain(UnconfinedTestDispatcher())
every { accountEvents.events } returns MutableSharedFlow()
viewModel = MainActivityViewModel(accountEvents, navigator, firebaseAuth, pdfService)
}
Expand Down

0 comments on commit b7ec2db

Please sign in to comment.