Package kotlin.test
Annotations to mark test functions and top-level functions for performing assertions in tests.
Types
Asserter
Abstracts the logic for performing assertions. Specific implementations of Asserter can use JUnit or TestNG assertion facilities.
interface Asserter
AsserterContributor
Checks applicability and provides Asserter instance
interface AsserterContributor
AssertionResult
Describes the result of an assertion execution.
interface AssertionResult
FrameworkAdapter
Serves as a bridge to a testing framework.
interface FrameworkAdapter
KotlinTestNamespace
interface KotlinTestNamespace
Annotations
AfterClass
Marks a function to be executed after a suite. Not supported in Kotlin/Common.
annotation class AfterClass
BeforeClass
Marks a function to be executed before a suite. Not supported in Kotlin/Common.
annotation class BeforeClass
BeforeTest
Marks a function to be invoked before each test.
annotation class BeforeTest
typealias BeforeTest = Before
typealias BeforeTest = BeforeEach
typealias BeforeTest = BeforeMethod
Properties
kotlinTestNamespace
val kotlinTestNamespace: KotlinTestNamespace
Functions
assertContains
Asserts that the array contains the specified element, with an optional message.
fun assertContains(
array: ShortArray,
element: Short,
message: String? = null
): Unit
fun assertContains(
array: BooleanArray,
element: Boolean,
message: String? = null
): Unit
fun assertContains(
array: UByteArray,
element: UByte,
message: String? = null
): Unit
fun assertContains(
array: UShortArray,
element: UShort,
message: String? = null
): Unit
fun assertContains(
array: ULongArray,
element: ULong,
message: String? = null
): Unit
Asserts that the range contains the specified value, with an optional message.
fun <T : Comparable<T>> assertContains(
range: ClosedRange<T>,
value: T,
message: String? = null
): Unit
fun <T : Comparable<T>> assertContains(
range: OpenEndRange<T>,
value: T,
message: String? = null
): Unit
fun assertContains(
range: ULongRange,
value: ULong,
message: String? = null
): Unit
Asserts that the charSequence contains the specified char, with an optional message.
fun assertContains(
charSequence: CharSequence,
char: Char,
ignoreCase: Boolean = false,
message: String? = null
): Unit
Asserts that the charSequence contains the specified other char sequence as a substring, with an optional message.
fun assertContains(
charSequence: CharSequence,
other: CharSequence,
ignoreCase: Boolean = false,
message: String? = null
): Unit
Asserts that the charSequence contains at least one match of the specified regular expression regex, with an optional message.
fun assertContains(
charSequence: CharSequence,
regex: Regex,
message: String? = null
): Unit
assertContentEquals
Asserts that the expected iterable is structurally equal to the actual iterable, with an optional message.
Asserts that the expected sequence is structurally equal to the actual sequence, with an optional message.
Asserts that the expected array is structurally equal to the actual array, with an optional message.
fun assertContentEquals(
expected: ShortArray?,
actual: ShortArray?,
message: String? = null
): Unit
fun assertContentEquals(
expected: FloatArray?,
actual: FloatArray?,
message: String? = null
): Unit
fun assertContentEquals(
expected: DoubleArray?,
actual: DoubleArray?,
message: String? = null
): Unit
fun assertContentEquals(
expected: BooleanArray?,
actual: BooleanArray?,
message: String? = null
): Unit
fun assertContentEquals(
expected: UByteArray?,
actual: UByteArray?,
message: String? = null
): Unit
fun assertContentEquals(
expected: UShortArray?,
actual: UShortArray?,
message: String? = null
): Unit
fun assertContentEquals(
expected: ULongArray?,
actual: ULongArray?,
message: String? = null
): Unit
assertEquals
Asserts that the difference between the actual and the expected is within an absoluteTolerance, with an optional message.
assertFailsWith
assertFalse
Asserts that the given block returns false
.
assertNotEquals
Asserts that the difference between the actual and the illegal is not within an absoluteTolerance, with an optional message.
assertNotNull
assertTrue
Asserts that the given block returns true
.
currentStackTrace
Returns an array of stack trace elements, each representing one stack frame. The first element of the array (assuming the array is not empty) represents the top of the stack, which is the place where currentStackTrace function was called from.
fun currentStackTrace(): Array<StackTraceElement>