diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index c5871cc..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/android/app/src/test/java/fr/iut/sciencequest/testRules/MainDispatcherRule.kt b/android/app/src/test/java/fr/iut/sciencequest/testRules/MainDispatcherRule.kt new file mode 100644 index 0000000..e571a61 --- /dev/null +++ b/android/app/src/test/java/fr/iut/sciencequest/testRules/MainDispatcherRule.kt @@ -0,0 +1,24 @@ +package fr.iut.sciencequest.testRules + +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.test.TestDispatcher +import kotlinx.coroutines.test.UnconfinedTestDispatcher +import kotlinx.coroutines.test.resetMain +import kotlinx.coroutines.test.setMain +import org.junit.rules.TestWatcher +import org.junit.runner.Description + +// simule le dispatcheurs utilisé par les ViewModels +@OptIn(ExperimentalCoroutinesApi::class) +class MainDispatcherRule( + private val testDispatcher: TestDispatcher = UnconfinedTestDispatcher() +) : TestWatcher() { + override fun starting(description: Description) { + Dispatchers.setMain(testDispatcher) + } + + override fun finished(description: Description) { + Dispatchers.resetMain() + } +} \ No newline at end of file