kotest-core / io.kotest.core.listeners / TestListener / beforeSpec

beforeSpec

open suspend fun beforeSpec(spec: Spec): Unit

This callback is invoked after the Engine instantiates a Spec to be used as part of a TestCase execution.

If a spec is instantiated multiple times - for example, if InstancePerTest or InstancePerLeaf isolation modes are used, then this callback will be invoked for each instance created, just before the first test (or only test) is executed for that spec.

This callback should be used if you need to perform setup each time a new spec instance is created. If you simply need to perform setup once per class file, then use prepareSpec.

Parameters

spec - the Spec instance.