kotest-core / io.kotest.core.test

Package io.kotest.core.test

Types

AssertionMode

AssertionMode is used to detect and warn a developer that a test does not execute any assertions. It is usually the case that if a test function does not execute some kind of assertion then the test is probably erroneous (see note). It is common to see junior developers write a test that does not actually test anything.

enum class AssertionMode

Description

The description gives the full path to a TestCase.

data class Description

EnabledIf

typealias EnabledIf = (TestCase) -> Boolean

NestedTest

data class NestedTest

TestCase

A TestCase describes an actual block of code that will be tested. It contains a reference back to the Spec instance in which it is being executed.

data class TestCase

TestCaseConfig

data class TestCaseConfig

TestCaseOrder

This enum is used to configure the order of root test execution in a Spec.

enum class TestCaseOrder

TestContext

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

abstract class TestContext : CoroutineScope

TestResult

data class TestResult

TestStatus

enum class TestStatus

TestType

enum class TestType

Exceptions

ZeroAssertionsError

class ZeroAssertionsError : AssertionError

Properties

DefaultTestCaseOrder

val DefaultTestCaseOrder: TestCaseOrder

Functions

createTestName

Creates a test name correctly handling focus and bang. If a prefix is specified, the focus/bang is moved to before the prefix.

fun createTestName(prefix: String, name: String): String

deriveTestConfig

Creates a TestCaseConfig from the given parameters, reverting to the receiver for null parameters.

fun TestCaseConfig.deriveTestConfig(enabled: Boolean? = null, tags: Set<Tag>? = null, extensions: List<TestCaseExtension>? = null, timeout: Duration? = null, enabledIf: EnabledIf? = null, invocations: Int? = null, threads: Int? = null, listeners: List<TestListener>? = null): TestCaseConfig

executeWithAssertionsCheck

Executes the given run function checking for the absense of assertions according to the receiver AssertionMode.

suspend fun AssertionMode.executeWithAssertionsCheck(name: String, run: suspend () -> Unit): Unit

isActive

Returns true if the given TestCase is active.

fun TestCase.isActive(): Boolean

isBang

Returns true if this test is disabled by being prefixed with a !

fun TestCase.isBang(): Boolean

isFocused

Returns true if this test is a focused test. That is, if the name starts with "f:".

fun TestCase.isFocused(): Boolean

resolvedAssertionMode

fun Spec.resolvedAssertionMode(): AssertionMode

resolvedTimeout

Returns the timeout for a TestCase taking into account global settings.

fun TestCaseConfig.resolvedTimeout(): Duration

toTestCase

fun NestedTest.toTestCase(spec: Spec, parent: Description): TestCase