diff options
| author | David Göransson <david.goransson@mullvad.net> | 2025-08-05 10:15:27 +0200 |
|---|---|---|
| committer | David Göransson <david.goransson@mullvad.net> | 2025-08-05 10:15:27 +0200 |
| commit | f240b49d638f3f9932de70dbb00d108e33b7670f (patch) | |
| tree | 75a71833287de24104ee99b4e19b5a90f74bb3e2 /android/lib/common-test/src | |
| parent | beed5dc2c6e161d431bd455ff42e262899224bd4 (diff) | |
| parent | 25d23887cc7f4fdd2e11cb39366489d49f33eab7 (diff) | |
| download | mullvadvpn-f240b49d638f3f9932de70dbb00d108e33b7670f.tar.xz mullvadvpn-f240b49d638f3f9932de70dbb00d108e33b7670f.zip | |
Merge branch 'flaky-test-addtimeviewmodeltest-droid-2101'
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 | 6 |
1 files changed, 6 insertions, 0 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 34d6739119..c73516f72d 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 @@ -10,6 +10,12 @@ import org.junit.jupiter.api.extension.AfterEachCallback import org.junit.jupiter.api.extension.BeforeEachCallback import org.junit.jupiter.api.extension.ExtensionContext +/** + * Should be applied to any test class that has a test subject that uses the main dispatcher. This + * is the default dispatcher for coroutines on Android and is for example used by the + * viewModelScope. This avoids test flakiness due to the test dispatcher eagerly starting coroutines + * instead of waiting for runCurrent for them to start. + */ @OptIn(ExperimentalCoroutinesApi::class) class TestCoroutineRule(val testDispatcher: TestDispatcher = UnconfinedTestDispatcher()) : BeforeEachCallback, AfterEachCallback { |
