-
Notifications
You must be signed in to change notification settings - Fork 1.9k
kotlinx-coroutines-test modules #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… finishing and complete README.md files
I've reviewed this PR and I have few questions or concerns. There is a number of APIs that were previously
|
I understand that making some test API from internal to public is to avoid, I can add a new Kotlin object in kotlin-coroutines-core module package kotlinx.coroutines.experimental.test
import kotlinx.coroutines.experimental.CommonPool
import kotlinx.coroutines.experimental.DefaultExecutor
public object Tests {
// used for tests
public fun usePrivatePool() {
CommonPool.usePrivatePool()
}
// used for tests
public fun shutdown(shutdownTimeout: Long) {
CommonPool.shutdown(shutdownTimeout)
DefaultExecutor.shutdown(shutdownTimeout)
}
}
And then call it from private val SHUTDOWN_TIMEOUT = 10_000L // 10s at most to wait
@Before
fun before() {
Tests.usePrivatePool()
threadsBefore = currentThreads()
}
@After
fun onCompletion() {
error.get()?.let { throw it }
check(actionIndex.get() == 0 || finished.get()) { "Expecting that 'finish(...)' was invoked, but it was not" }
Tests.shutdown(SHUTDOWN_TIMEOUT )
checkTestThreads(threadsBefore)
} Maybe the I am planning to integrate |
…(in src/test/kotlin)
…utines-core (in src/test/kotlin) All StressTests are named *StressTest
…-test-js projects
@elizarov can you review this PR again ? I think coroutine-guide.md should be completed with a Testing part, describing how to use |
add 3 new dedicated kotlinx-coroutines-test projects (common, JVM and JS)
Solves #336