-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AN/USER] refactor: ViewModel Test Code Dispatcher Rule 추가 (#590)
* feat: coroutine dispatcher main rule 추가 * refactor: 티켓 예매 화면 ViewModel 테스트 리팩터링 * refactor: 티켓 목록 화면 ViewModel 테스트 리팩터링 * refactor: 티켓 기록 화면 ViewModel 테스트 리팩터링 * refactor: 티켓 입장 화면 ViewModel 테스트 리팩터링 * refactor: 학생 인증 화면 ViewModel 테스트 리팩터링 * refactor: 로그인 화면 ViewModel 테스트 리팩터링 * refactor: 학교 선택 화면 ViewModel 테스트 리팩터링 * refactor: 마이페이지 화면 ViewModel 테스트 리팩터링 * refactor: 홈 화면 ViewModel 테스트 리팩터링 * refactor: 축제 목록 화면 ViewModel 테스트 리팩터링 * refactor: 마이페이지 화면 ViewModel 테스트 재변경
- Loading branch information
1 parent
f781fe5
commit 8550e89
Showing
11 changed files
with
85 additions
and
144 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
...oid/festago/app/src/test/java/com/festago/festago/presentation/rule/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,28 @@ | ||
package com.festago.festago.presentation.rule | ||
|
||
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 | ||
|
||
// Reusable JUnit4 TestRule to override the Main dispatcher | ||
class MainDispatcherRule | ||
@OptIn(ExperimentalCoroutinesApi::class) | ||
constructor( | ||
private val testDispatcher: TestDispatcher = UnconfinedTestDispatcher(), | ||
) : TestWatcher() { | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
override fun starting(description: Description) { | ||
Dispatchers.setMain(testDispatcher) | ||
} | ||
|
||
@OptIn(ExperimentalCoroutinesApi::class) | ||
override fun finished(description: Description) { | ||
Dispatchers.resetMain() | ||
} | ||
} |
20 changes: 6 additions & 14 deletions
20
...d/festago/app/src/test/java/com/festago/festago/presentation/ui/home/HomeViewModelTest.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
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
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
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
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
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
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
Oops, something went wrong.