для coroutinetestrule я добавил CoroutineteStextension, но он не работает хорошо, когда параллельные тестируемы как, < /p>
Код: Выделить всё
Dispatchers.Main is used concurrently with setting it.Код: Выделить всё
Dispatchers.Main is modified concurrentlyКод: Выделить всё
junit.jupiter.execution.parallel.enabled = true junit.jupiter.execution.parallel.mode.default = concurrentcoroutinetestextension.kt
Код: Выделить всё
@OptIn(ExperimentalCoroutinesApi::class)
class CoroutineTestExtension(
@Suppress("ForbiddenImport")
coroutineTestDispatcher: TestDispatcher = kotlinx.coroutines.test.UnconfinedTestDispatcher()
) : Extension, BeforeAllCallback, AfterAllCallback {
val testDispatcher: TestDispatcher = coroutineTestDispatcher
val testScope = TestScope(testDispatcher)
override fun beforeAll(context: ExtensionContext?) {
Dispatchers.setMain(testDispatcher)
}
override fun afterAll(context: ExtensionContext?) {
Dispatchers.resetMain()
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... bled-in-ju
Мобильная версия