diff options
Diffstat (limited to 'android/lib/common-test/src')
| -rw-r--r-- | android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt b/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt index d04983be26..34d6739119 100644 --- a/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt +++ b/android/lib/common-test/src/main/java/net/mullvad/mullvadvpn/lib/common/test/TestCoroutineRule.kt @@ -6,22 +6,20 @@ 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 +import org.junit.jupiter.api.extension.AfterEachCallback +import org.junit.jupiter.api.extension.BeforeEachCallback +import org.junit.jupiter.api.extension.ExtensionContext @OptIn(ExperimentalCoroutinesApi::class) class TestCoroutineRule(val testDispatcher: TestDispatcher = UnconfinedTestDispatcher()) : - TestWatcher() { + BeforeEachCallback, AfterEachCallback { - override fun starting(description: Description) { - super.starting(description) + override fun beforeEach(var1: ExtensionContext?) { Dispatchers.setMain(testDispatcher) } - override fun finished(description: Description) { - super.finished(description) + override fun afterEach(var1: ExtensionContext?) { Dispatchers.resetMain() - // Replacement for cleanupTestCoroutines() testDispatcher.scheduler.runCurrent() } } |
