kotest-core / io.kotest.core.spec / TestConfiguration

TestConfiguration

abstract class TestConfiguration

The parent of all configuration DSL objects and contains configuration methods common to both Spec and TestFactoryConfiguration implementations.

Constructors

<init>

The parent of all configuration DSL objects and contains configuration methods common to both Spec and TestFactoryConfiguration implementations.

TestConfiguration()

Properties

assertions

Sets an assertion mode which is applied to every test.

var assertions: AssertionMode?

defaultTestConfig

Config applied to each test case if not overridden per test case. If left null, then defaults to the project config default.

var defaultTestConfig: TestCaseConfig?

Functions

afterProject

Registers a callback that will execute after all specs have completed. This is a convenience method for creating a ProjectListener and registering it.

fun afterProject(f: AfterProject): Unit

afterSpec

fun afterSpec(f: AfterSpec): Unit

afterTest

Registers a new after-test callback to be executed after every TestCase. The callback provides two parameters - the test case that has just completed, and the TestResult outcome of that test.

abstract fun afterTest(f: AfterTest): Unit

aroundSpec

fun aroundSpec(aroundSpecFn: AroundSpecFn): Unit

aroundTest

fun aroundTest(aroundTestFn: AroundTestFn): Unit

beforeSpec

fun beforeSpec(f: BeforeSpec): Unit

beforeTest

Registers a new before-test callback to be executed before every TestCase. The TestCase about to be executed is provided as the parameter.

abstract fun beforeTest(f: BeforeTest): Unit

extension

fun extension(f: TestCaseExtensionFn): Unit

extensions

fun extensions(vararg extensions: TestCaseExtension): Unit

finalizeSpec

fun finalizeSpec(f: FinalizeSpec): Unit

include

Include the tests from the given TestFactory in this configuration.

fun include(factory: TestFactory): Unit

Includes the tests from the given TestFactory with the root tests of the factory given the prefix.

fun include(prefix: String, factory: TestFactory): Unit

listener

fun listener(listener: TestListener): Unit

listeners

fun listeners(vararg listener: TestListener): Unit

prepareSpec

fun prepareSpec(f: PrepareSpec): Unit

tags

Adds Tags to this factory, which will be applied to each test case generated by this TestFactoryConfiguration. When this factory is included in a Spec, only the tests generated from this factory will have these tags applied.

fun tags(vararg tags: Tag): Unit

Extension Functions

autoClose

Closes an AutoCloseable when the spec is completed by registering an afterSpec listener which invokes the AutoCloseable.close method.

fun <T : AutoCloseable> TestConfiguration.autoClose(closeable: T): T

Closes a lazy AutoCloseable when the spec is completed by registering an afterSpec listener which invokes the AutoCloseable.close method.

fun <T : AutoCloseable> TestConfiguration.autoClose(closeable: Lazy<T>): Lazy<T>

tempfile

fun TestConfiguration.tempfile(prefix: String? = null, suffix: String? = ".tmp"): File

Inheritors

Spec

abstract class Spec : TestConfiguration, SpecConfigurationMethods

TestFactoryConfiguration

A TestFactoryConfiguration provides a DSL to allow for easy creation of a TestFactory when this class is the receiver of a lambda parameter.

abstract class TestFactoryConfiguration : TestConfiguration