All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmTest.JobStructuredJoinStressTest.kt Maven / Gradle / Ivy

There is a newer version: 1.4.2-native-mt
Show newest version
/*
 * Copyright 2016-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
 */

package kotlinx.coroutines

import org.junit.*

/**
 * Test a race between job failure and join.
 *
 * See [#1123](https://github.com/Kotlin/kotlinx.coroutines/issues/1123).
 */
class JobStructuredJoinStressTest : TestBase() {
    private val nRepeats = 1_000 * stressTestMultiplier

    @Test
    fun testStress() {
        repeat(nRepeats) {
            assertFailsWith {
                runBlocking {
                    // launch in background
                    val job = launch(Dispatchers.Default) {
                        throw TestException("OK") // crash
                    }
                    assertFailsWith {
                        job.join()
                    }
                }
            }
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy