-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from ku-ring/2.0/kuring-101_test_yk
kuring-101 FeedbackViewModel unit test 수정, MainDispatcherRule 추가
- Loading branch information
Showing
2 changed files
with
49 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
feature/feedback/src/test/java/com/ku_stacks/ku_ring/feedback/util/MainDispatcherRule.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.ku_stacks.ku_ring.feedback.util | ||
|
||
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 | ||
|
||
@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() | ||
} | ||
} |