Skip to content

PreparedSpec

abstract class PreparedSpec(body: SuiteDsl.() -> Unit) : StringSpec

Constructors

PreparedSpec

constructor(body: SuiteDsl.() -> Unit)

Properties

assertionMode

var assertionMode: AssertionMode?

assertions

var assertions: AssertionMode?

assertSoftly

blockingTest

coroutineDebugProbes

coroutineDispatcherFactory

var coroutineDispatcherFactory: CoroutineDispatcherFactory?

coroutineTestScope

defaultTestConfig

var defaultTestConfig: DefaultTestConfig?

duplicateTestNameMode

var duplicateTestNameMode: DuplicateTestNameMode?

extensions

open val extensions: List<Extension>

failfast

invocationTimeout

isolationMode

var isolationMode: IsolationMode?

nonDeterministicTestVirtualTimeEnabled

retries

var retries: Int?

retryDelay

scope

@ExperimentalKotest



lateinit var scope: CoroutineScope

severity

var severity: TestCaseSeverityLevel?

testCaseOrder

var testCaseOrder: TestCaseOrder?

testExecutionMode

var testExecutionMode: TestExecutionMode?

testOrder

var testOrder: TestCaseOrder?

timeout

var timeout: Long?

Functions

add

open override fun add(test: RootTest)

afterAny

fun afterAny(f: AfterAny)
open suspend fun afterAny(testCase: TestCase, result: TestResult)

afterContainer

fun afterContainer(f: AfterContainer)
open suspend fun afterContainer(testCase: TestCase, result: TestResult)

afterEach

fun afterEach(f: AfterEach)
open suspend fun afterEach(testCase: TestCase, result: TestResult)

afterInvocation

fun afterInvocation(f: AfterInvocation)

afterProject

fun afterProject(f: AfterProject)

afterSpec

open suspend fun afterSpec(spec: Spec)
override fun afterSpec(f: AfterSpec)

afterTest

override fun afterTest(f: AfterTest)
open suspend fun afterTest(testCase: TestCase, result: TestResult)

aroundTest

fun aroundTest(aroundTestFn: AroundTestFn)

assertionMode

open fun assertionMode(): AssertionMode?

autoClose

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

autoCloseables

fun autoCloseables(): List<Lazy<AutoCloseable>>

beforeAny

fun beforeAny(f: BeforeAny)
open suspend fun beforeAny(testCase: TestCase)

beforeContainer

fun beforeContainer(f: BeforeContainer)
open suspend fun beforeContainer(testCase: TestCase)

beforeEach

fun beforeEach(f: BeforeEach)
open suspend fun beforeEach(testCase: TestCase)

beforeInvocation

fun beforeInvocation(f: BeforeInvocation)

beforeSpec

fun beforeSpec(f: BeforeSpec)
open suspend fun beforeSpec(spec: Spec)

beforeTest

open suspend fun beforeTest(testCase: TestCase)
override fun beforeTest(f: BeforeTest)

config

open fun String.config(config: TestConfig, test: suspend TestScope.() -> Unit)
open fun String.config(
    enabled: Boolean?, 
    invocations: Int?, 
    threads: Int?, 
    tags: Set<Tag>?, 
    timeout: Duration?, 
    extensions: List<TestCaseExtension>?, 
    enabledIf: EnabledIf?, 
    invocationTimeout: Duration?, 
    severity: TestCaseSeverityLevel?, 
    enabledOrReasonIf: EnabledOrReasonIf?, 
    coroutineDebugProbes: Boolean?, 
    blockingTest: Boolean?, 
    coroutineTestScope: Boolean?, 
    test: suspend TestScope.() -> Unit
)

coroutineDispatcherFactory

open fun coroutineDispatcherFactory(): CoroutineDispatcherFactory?

duplicateTestNameMode

open fun duplicateTestNameMode(): DuplicateTestNameMode?

extension

fun extension(f: TestCaseExtensionFn)
fun <T : Extension> extension(extension: T): T

extensions

fun extensions(): List<Extension>
fun extensions(vararg extensions: Extension)
fun extensions(extensions: List<Extension>)

include

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

invocationTimeout

open fun invocationTimeout(): Long?

invoke

open operator fun String.invoke(test: suspend StringSpecScope.() -> Unit)

isolationMode

open fun isolationMode(): IsolationMode?

preparedSuite

fun RootScope.preparedSuite(config: TestConfig = TestConfig.Empty, block: SuiteDsl.() -> Unit)

Executes a Prepared SuiteDsl in a Kotest suite.

Since Kotest cannot represent nested non-suspending test suites, all nested suites are declared at the top-level of the provided RootScope. The name of the suite is appended at the start of the tests, so the suite structure is not lost.

Example

This example uses StringSpec, but tests can be registered using any spec.

class MyTests : StringSpec({
    "A regular Kotest test" {
        // …
    }

    preparedSuite {
        test("A regular Prepared test") {
            // …
        }

        suite("A regular Prepared test suite") {
            // …
        }
    }
})

register

fun <T : Extension> register(extension: T): T

registeredAutoCloseables

fun registeredAutoCloseables(): List<Lazy<AutoCloseable>>

rootTests

open override fun rootTests(): List<RootTest>

seal

fun seal()

tags

open override fun tags(vararg tags: Tag)
open fun tags(): Set<Tag>

testCaseOrder

open fun testCaseOrder(): TestCaseOrder?

testExecutionMode

open fun testExecutionMode(): TestExecutionMode?

timeout

open fun timeout(): Long?