James Eschner
04/01/2021, 4:50 PMTestFactory
and trying to understand the lifecycle. It appears that the beforeTest
/`afterTest` functions are executed but not the `beforeSpec`/`afterSpec` functions. Can someone help me understand why?
Code:
val myTestFactory: TestFactory = shouldSpec {
beforeSpec {
println("beforeSpec")
}
beforeTest {
println("beforeTest")
}
afterSpec {
println("afterSpec")
}
afterTest {
println("afterTest")
}
should("help me understand the factory lifecycle") {
println("during")
}
}
class MyTest : ShouldSpec({
include(myTestFactory)
})
Output:
~~~ Kotest Configuration ~~~
-> Parallelization factor: 1
-> Default test timeout: 600000ms
-> Default test order: Sequential
-> Default isolation mode: SingleInstance
-> Global soft assertations: False
-> Write spec failure file: False
-> Fail on ignored tests: False
-> Spec execution order: SpecExecutionOrder
-> Extensions
- io.kotest.engine.extensions.SystemPropertyTagExtension
- io.kotest.core.extensions.RuntimeTagExtension
- io.kotest.engine.extensions.RuntimeTagExpressionExtension
beforeTest
during
afterTest
MyTest > should help me understand the factory lifecycle PASSED
* Not a Contribution *sam
04/01/2021, 7:29 PMJames Eschner
04/01/2021, 10:59 PMTestFactory
can have more than one test in it it makes sense for it to have a lifecycle that’s similar to a regular spec. What I mean is that there should be facilities to run arbitrary code before and after each test as well as before and after all tests.
* Not a Contribution *sam
04/01/2021, 11:33 PMLeoColman
04/02/2021, 6:59 AMJames Eschner
04/02/2021, 1:05 PMbeforeGroup
or beforeFactory
both seem reasonable. This would be awesome to have, it took me some time to figure out what was going wrong.
* Not a Contribution *christophsturm
04/02/2021, 3:14 PMsam
04/02/2021, 3:15 PMJames Eschner
04/02/2021, 3:42 PMTestListener
that implements `beforeSpec`/`afterSpec` inside of a TestFactory
* Not a Contribution *