kotest-core / io.kotest.core.engine / SpecRunner

SpecRunner

abstract class SpecRunner

The base class for executing all the tests inside a Spec.

Each spec can define how tests are isolated from each other, via an IsolationMode.

Parameters

listener - provides callbacks on tests as they are executed. These callbacks are used to ultimately feed back into the test engine implementation.

Constructors

<init>

The base class for executing all the tests inside a Spec.

SpecRunner(listener: TestEngineListener)

Properties

listener

provides callbacks on tests as they are executed. These callbacks are used to ultimately feed back into the test engine implementation.

val listener: TestEngineListener

Functions

createInstance

Creates an instance of the supplied Spec by delegating to the project constructors, and notifies the TestEngineListener of the instantiation event.

fun createInstance(kclass: KClass<out Spec>): Try<Spec>

execute

Executes all the tests in this spec, returning a Failure if there was an exception in a listener or class initializer. Otherwise returns the results for the tests in that spec.

abstract suspend fun execute(spec: Spec): Try<Map<TestCase, TestResult>>

Inheritors

InstancePerLeafSpecRunner

class InstancePerLeafSpecRunner : SpecRunner

InstancePerTestSpecRunner

Implementation of SpecRunner that executes each TestCase in a fresh instance of the Spec class.

class InstancePerTestSpecRunner : SpecRunner

SingleInstanceSpecRunner

Implementation of SpecRunner that executes all tests against the same Spec instance. In other words, only a single instance of the spec class is instantiated for all the test cases.

class SingleInstanceSpecRunner : SpecRunner