PreparedSpec¶
abstract class PreparedSpec(body: PreparedSpec.() -> Unit, config: TestConfig = TestConfig.Empty) : AbstractSpec, SuiteDsl
Declares a Prepared test suite using the Kotest framework.
Install the Kotest IntelliJ plugin to have gutter icons to run a specific test.
Example¶
Constructors¶
PreparedSpec¶
constructor(body: PreparedSpec.() -> Unit, config: TestConfig = TestConfig.Empty)
Properties¶
assertionMode¶
var assertionMode: AssertionMode?
assertions¶
var assertions: AssertionMode?
assertSoftly¶
var assertSoftly: Boolean?
blockingTest¶
var blockingTest: Boolean?
coroutineDebugProbes¶
var coroutineDebugProbes: Boolean?
coroutineDispatcherFactory¶
var coroutineDispatcherFactory: CoroutineDispatcherFactory?
coroutineTestScope¶
var coroutineTestScope: Boolean?
defaultTestConfig¶
var defaultTestConfig: DefaultTestConfig?
duplicateTestNameMode¶
var duplicateTestNameMode: DuplicateTestNameMode?
extensions¶
open val extensions: List<Extension>
failfast¶
invocationTimeout¶
var invocationTimeout: Long?
isolationMode¶
var isolationMode: IsolationMode?
metadata¶
val metadata: TestMetadata
nonDeterministicTestVirtualTimeEnabled¶
@KotestInternal
var nonDeterministicTestVirtualTimeEnabled: Boolean
retries¶
retryDelay¶
var retryDelay: Duration?
scope¶
@ExperimentalKotest
@KotestInternal
lateinit var scope: CoroutineScope
severity¶
var severity: TestCaseSeverityLevel?
testCaseOrder¶
var testCaseOrder: TestCaseOrder?
testExecutionMode¶
var testExecutionMode: TestExecutionMode?
testOrder¶
var testOrder: TestCaseOrder?
timeout¶
Functions¶
add¶
open override fun add(test: RootTest)
open override fun add(test: TestDefinition)
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¶
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)
coroutineDispatcherFactory¶
open fun coroutineDispatcherFactory(): CoroutineDispatcherFactory?
duplicateTestNameMode¶
open fun duplicateTestNameMode(): DuplicateTestNameMode?
extension¶
fun extension(f: TestCaseExtensionFn)
extensions¶
fun extensions(): List<Extension>
fun extensions(extensions: List<Extension>)
fun extensions(vararg extensions: Extension)
finalizeSpec¶
fun finalizeSpec(f: FinalizeSpec)
include¶
fun include(factory: TestFactory)
invocationTimeout¶
open fun invocationTimeout(): Long?
isolationMode¶
open fun isolationMode(): IsolationMode?
preparedSuite¶
fun AbstractSpec.preparedSuite(config: TestConfig = TestConfig.Empty, block: KotestSuiteDsl.() -> Unit)
Executes a Prepared SuiteDsl in an existing Kotest suite.
To create a Prepared-specific suite, see PreparedSpec.
Example
This example uses StringSpec, but tests can be registered using any spec.
register¶
registeredAutoCloseables¶
fun registeredAutoCloseables(): List<Lazy<AutoCloseable>>
suite¶
@JvmName(name = "suiteKotest")
fun suite(
name: String,
config: TestConfig = TestConfig.Empty,
block: KotestSuiteDsl.() -> Unit
)
Creates a child suite named name of the current suite.
Simple example
suite("An example") {
test("A test") { … }
suite("A nested suite") {
test("A nested test 1") { … }
test("A nested test 2") { … }
}
}
Test configuration
The default configuration for all tests can be passed with the config parameter:
To learn more about the available configuration options, see the subtypes of TestConfig.Element.
tags¶
open override fun tags(vararg tags: Tag)
test¶
open override fun test(
name: String,
config: TestConfig,
block: suspend TestDsl.() -> Unit
)
testCaseOrder¶
open fun testCaseOrder(): TestCaseOrder?
testExecutionMode¶
open fun testExecutionMode(): TestExecutionMode?