Skip to content

Instantly share code, notes, and snippets.

@jschneidereit
Created October 7, 2020 17:25
Show Gist options
  • Save jschneidereit/22aa496ca2d62cf7381245507fd6afa2 to your computer and use it in GitHub Desktop.
Save jschneidereit/22aa496ca2d62cf7381245507fd6afa2 to your computer and use it in GitHub Desktop.
import io.kotest.core.config.AbstractProjectConfig
import io.kotest.core.spec.IsolationMode
import io.kotest.core.spec.style.ShouldSpec
import kotlinx.coroutines.delay
import java.time.LocalDateTime
import kotlin.time.ExperimentalTime
import kotlin.time.TimeMark
import kotlin.time.TimeSource
@OptIn(ExperimentalTime::class)
object ProjectConfig : AbstractProjectConfig() {
override val parallelism = 4
override val isolationMode = IsolationMode.InstancePerTest
lateinit var watch: TimeMark
override fun beforeAll() {
watch = TimeSource.Monotonic.markNow()
super.beforeAll()
}
override fun afterAll() {
println("completed tests after ${watch.elapsedNow()}")
super.afterAll()
}
}
class ASampleTests : ShouldSpec({
beforeSpec {
println("Starting spec at ${LocalDateTime.now()}")
}
should("a") {
delay(5000L)
}
should("b") {
delay(5000L)
}
})
class BSampleTests : ShouldSpec({
beforeSpec {
println("Starting spec at ${LocalDateTime.now()}")
}
should("c") {
delay(5000L)
}
should("d") {
delay(5000L)
}
})
@jschneidereit
Copy link
Author

Starting spec at 2020-10-07T10:23:15.497129
Starting spec at 2020-10-07T10:23:20.672335
Starting spec at 2020-10-07T10:23:15.514699
Starting spec at 2020-10-07T10:23:20.694341
completed tests after 10.3s
completed tests after 10.3s

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment