Jim
10/07/2020, 5:20 PMval tests: List<TestCase>
suspend fun executeAsync(testCase: TestCase...): Deferred<TestResult>...
fun doIt() = tests.map { executeAsync(it) }.awaitAll() // or just start them instead
If my failsafe retries were kotlin's delay
then my other tests would run whatever they can instead of waiting for each test case to complete serially, at least that's the way I understand it.awaitAll
in my pseudocode would just be a list of `TestResult`ssam
10/07/2020, 5:22 PMJim
10/07/2020, 5:25 PMoverride val parallelism = 4
override val isolationMode = IsolationMode.InstancePerTest
but the tests within each spec even though they generate separate specs always ran in serialsam
10/07/2020, 5:25 PMJim
10/07/2020, 5:25 PMsam
10/07/2020, 5:25 PMJim
10/07/2020, 5:25 PMsam
10/07/2020, 5:26 PMJim
10/07/2020, 5:26 PMsam
10/07/2020, 5:27 PMJim
10/07/2020, 5:29 PMsam
10/07/2020, 5:29 PMJim
10/07/2020, 5:29 PMsam
10/07/2020, 5:30 PMJim
10/07/2020, 5:34 PMsam
10/07/2020, 5:52 PMJim
10/07/2020, 5:59 PMsam
10/07/2020, 5:59 PMJim
10/07/2020, 6:00 PMsam
10/07/2020, 6:01 PMJim
10/07/2020, 6:03 PMsam
10/07/2020, 6:04 PMJim
10/07/2020, 6:14 PMsam
10/07/2020, 6:14 PMJim
10/07/2020, 6:41 PMexecuteAndWait
is where some of the magic happens and that one looks pretty intense 😂sam
10/07/2020, 6:41 PMJim
10/07/2020, 6:42 PMSpecFunctionCallbacks
being marked with suspend?sam
10/09/2020, 5:54 PMJim
10/09/2020, 5:54 PMsam
10/09/2020, 5:54 PMJim
10/09/2020, 5:55 PMsam
10/09/2020, 5:55 PMclass MyTest : FunSpec() {
init {
beforeSpec { ... }
}
}
class MyTest : FunSpec({
beforeSpec { ... }
})
Jim
10/09/2020, 5:56 PMsam
10/09/2020, 5:56 PMJim
10/09/2020, 5:56 PMsam
10/09/2020, 5:59 PMJim
10/09/2020, 5:59 PMabstract class ValidationSpec(body: FunSpecBody = {}) : FunSpec(body) {
init {
beforeSpec {
assertServerAccessible()
}
afterSpec {
cleanupStuff()
}
}
this is what i'm going forbody
param prevents me from doing it the scala waysam
10/09/2020, 6:26 PMbeforeSpec(setup)
where setup is a function Spec -> Unit
or whatever the spec isJim
10/09/2020, 6:27 PMsam
10/09/2020, 6:27 PMobject/class Something : TestListener { ... override here }
and pass it into multiple specs via listener(mything)
Jim
10/09/2020, 6:27 PMlateinit var
e.g.:
lateinit var version: Version
beforeSpec {
version = getServerVersion()
}
but perhaps just assigning version and allowing it to happen at construction of the spec time is fine, since it really needs to happen before any tests not necessarily before the spec 🤔sam
10/09/2020, 6:35 PMobject MyListener: TestListener {
val version: Version = ....
override fun beforeSpec ...
override fun afterSpec...
}
class MyTest: FunSpec {
init {
listener(MyListener)
test("xx") { }
}
}
Jim
10/09/2020, 6:35 PMsam
10/09/2020, 6:35 PMclass MyTest: FunSpec {
init {
val listener = listener(MyInstance())
test("xx") {
// use listener here
}
}
}
Jim
10/09/2020, 6:36 PMsam
10/09/2020, 6:39 PMval processorListener = IngestionProcessorTestListener()
listener(startStopKafka)
listener(processorListener)
listener(resetDatabase)
val startStopKafka = object : TestListener {
override suspend fun beforeSpec(spec: Spec) {
EmbeddedKafka.start(EmbeddedKafkaConfig.defaultConfig())
while (!EmbeddedKafka.isRunning()) {
Thread.sleep(100)
}
}
override suspend fun afterSpec(spec: Spec) {
EmbeddedKafka.stop()
}
}
Jim
10/09/2020, 6:40 PMsam
10/09/2020, 6:40 PMJim
10/09/2020, 6:41 PMsam
10/09/2020, 6:41 PMJim
10/09/2020, 6:42 PMsam
10/09/2020, 6:47 PMJim
10/09/2020, 6:48 PMJim
10/09/2020, 6:49 PMsam
10/09/2020, 6:49 PMcode here
runTest()
code here
Jim
10/09/2020, 6:50 PMsam
10/09/2020, 6:50 PMJim
10/09/2020, 6:51 PMsam
10/09/2020, 6:51 PMJim
10/09/2020, 6:51 PM