kotest-core / io.kotest.core.test / TestContext

TestContext

abstract class TestContext : CoroutineScope

A TestContext is used as the receiver of a closure that is associated with a TestCase.

This allows the scope body to interact with the test engine, for instance, adding metadata during a test, inspecting the current TestCaseConfig, or notifying the runtime of a nested test.

The test context extends CoroutineScope giving the ability for any test closure to launch coroutines directly, without requiring them to create a scope.

Constructors

<init>

A TestContext is used as the receiver of a closure that is associated with a TestCase.

TestContext()

Properties

testCase

The currently executing TestCase.

abstract val testCase: TestCase

Functions

invoke

infix operator fun String.invoke(ignored: suspend TestContext.() -> Unit): Unit

registerTestCase

Creates a NestedTest and then registers with the TestContext.

suspend fun registerTestCase(name: String, test: suspend TestContext.() -> Unit, config: TestCaseConfig, type: TestType): Unit

Notifies the test runner about a test in a nested scope.

abstract suspend fun registerTestCase(nested: NestedTest): Unit