Package-level declarations

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Annotations to mark test functions and top-level functions for performing assertions in tests.

Types

Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class AfterClass

Marks a function to be executed after a suite. Not supported in Kotlin/Common.

Since Kotlin 1.3
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
expect annotation class AfterTest

Marks a function to be invoked after each test.

Since Kotlin 1.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest

Marks a function to be invoked after each test.

Since Kotlin 1.1
actual typealias AfterTest = After
Since Kotlin 1.0
actual typealias AfterTest = AfterEach
Since Kotlin 1.0
actual typealias AfterTest = AfterMethod
Since Kotlin 1.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest

Marks a function to be invoked after each test.

Since Kotlin 1.3
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest

Marks a function to be invoked after each test.

Since Kotlin 1.8
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class AfterTest

Marks a function to be invoked after each test.

Since Kotlin 1.8
Link copied to clipboard
interface Asserter

Abstracts the logic for performing assertions. Specific implementations of Asserter can use JUnit or TestNG assertion facilities.

Since Kotlin 1.0
Link copied to clipboard

Checks applicability and provides Asserter instance

Since Kotlin 1.0
Link copied to clipboard
external interface AssertionResult

Describes the result of an assertion execution.

Since Kotlin 1.1
interface AssertionResult

Describes the result of an assertion execution.

Since Kotlin 1.8
interface AssertionResult

Describes the result of an assertion execution.

Since Kotlin 1.8
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
annotation class BeforeClass

Marks a function to be executed before a suite. Not supported in Kotlin/Common.

Since Kotlin 1.3
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
expect annotation class BeforeTest

Marks a function to be invoked before each test.

Since Kotlin 1.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class BeforeTest

Marks a function to be invoked before each test.

Since Kotlin 1.1
actual typealias BeforeTest = Before
Since Kotlin 1.0
actual typealias BeforeTest = BeforeEach
Since Kotlin 1.0
actual typealias BeforeTest = BeforeMethod
Since Kotlin 1.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class BeforeTest

Marks a function to be invoked before each test.

Since Kotlin 1.3
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class BeforeTest

Marks a function to be invoked before each test.

Since Kotlin 1.8
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class BeforeTest

Marks a function to be invoked before each test.

Since Kotlin 1.8
Link copied to clipboard

Default Asserter implementation to avoid dependency on JUnit or TestNG.

Since Kotlin 1.0
Link copied to clipboard
external interface FrameworkAdapter

Serves as a bridge to a testing framework.

Since Kotlin 1.1

Serves as a bridge to a testing framework.

Since Kotlin 1.8

Serves as a bridge to a testing framework.

Since Kotlin 1.8
Link copied to clipboard
expect annotation class Ignore

Marks a test or a suite as ignored.

Since Kotlin 1.0
actual annotation class Ignore

Marks a test or a suite as ignored.

Since Kotlin 1.1
actual typealias Ignore = org.junit.Ignore
Since Kotlin 1.0
actual typealias Ignore = Disabled
Since Kotlin 1.0
actual typealias Ignore = org.testng.annotations.Ignore
Since Kotlin 1.0
actual annotation class Ignore

Marks a test or a suite as ignored.

Since Kotlin 1.3
actual annotation class Ignore

Marks a test or a suite as ignored.

Since Kotlin 1.8
actual annotation class Ignore

Marks a test or a suite as ignored.

Since Kotlin 1.8
Link copied to clipboard
external interface KotlinTestNamespace
Since Kotlin 1.1
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
expect annotation class Test

Marks a function as a test.

Since Kotlin 1.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class Test

Marks a function as a test.

Since Kotlin 1.1
actual typealias Test = org.junit.Test
Since Kotlin 1.0
actual typealias Test = org.junit.jupiter.api.Test
Since Kotlin 1.0
actual typealias Test = org.testng.annotations.Test
Since Kotlin 1.0
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class Test

Marks a function as a test.

Since Kotlin 1.3
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class Test

Marks a function as a test.

Since Kotlin 1.8
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
actual annotation class Test

Marks a function as a test.

Since Kotlin 1.8

Properties

Link copied to clipboard

Current adapter providing assertion implementations

Since Kotlin 1.0
Link copied to clipboard
Since Kotlin 1.1

Functions

Link copied to clipboard
fun <T> assertContains(sequence: <Error class: unknown class><T>, element: T, message: String? = null)

Asserts that the sequence contains the specified element, with an optional message.

Since Kotlin 1.5
fun assertContains(array: <Error class: unknown class>, element: <Error class: unknown class>, message: String? = null)
fun assertContains(array: <Error class: unknown class>, element: <Error class: unknown class>, message: String? = null)
fun assertContains(array: <Error class: unknown class>, element: <Error class: unknown class>, message: String? = null)
fun assertContains(array: <Error class: unknown class>, element: <Error class: unknown class>, message: String? = null)
fun <T> assertContains(array: Array<T>, element: T, message: String? = null)
fun assertContains(array: BooleanArray, element: Boolean, message: String? = null)
fun assertContains(array: ByteArray, element: Byte, message: String? = null)
fun assertContains(array: CharArray, element: Char, message: String? = null)
fun assertContains(array: IntArray, element: Int, message: String? = null)
fun assertContains(array: LongArray, element: Long, message: String? = null)
fun assertContains(array: ShortArray, element: Short, message: String? = null)

Asserts that the array contains the specified element, with an optional message.

Since Kotlin 1.5
fun assertContains(range: <Error class: unknown class>, value: <Error class: unknown class>, message: String? = null)
fun assertContains(range: <Error class: unknown class>, value: <Error class: unknown class>, message: String? = null)
fun assertContains(range: CharRange, value: Char, message: String? = null)
fun <T : Comparable<T>> assertContains(range: ClosedRange<T>, value: T, message: String? = null)
fun assertContains(range: IntRange, value: Int, message: String? = null)
fun assertContains(range: LongRange, value: Long, message: String? = null)

Asserts that the range contains the specified value, with an optional message.

Since Kotlin 1.5
fun assertContains(charSequence: CharSequence, regex: <Error class: unknown class>, message: String? = null)

Asserts that the charSequence contains at least one match of the specified regular expression regex, with an optional message.

Since Kotlin 1.5
fun <T> assertContains(iterable: Iterable<T>, element: T, message: String? = null)

Asserts that the iterable contains the specified element, with an optional message.

Since Kotlin 1.5
fun <K, V> assertContains(map: Map<K, V>, key: K, message: String? = null)

Asserts that the map contains the specified key, with an optional message.

Since Kotlin 1.5
fun <T : Comparable<T>> assertContains(range: OpenEndRange<T>, value: T, message: String? = null)

Asserts that the range contains the specified value, with an optional message.

Since Kotlin 1.7
fun assertContains(charSequence: CharSequence, char: Char, ignoreCase: Boolean = false, message: String? = null)

Asserts that the charSequence contains the specified char, with an optional message.

Since Kotlin 1.5
fun assertContains(charSequence: CharSequence, other: CharSequence, ignoreCase: Boolean = false, message: String? = null)

Asserts that the charSequence contains the specified other char sequence as a substring, with an optional message.

Since Kotlin 1.5
Link copied to clipboard
fun <T> assertContentEquals(expected: <Error class: unknown class><T>?, actual: <Error class: unknown class><T>?, message: String? = null)

Asserts that the expected sequence is structurally equal to the actual sequence, with an optional message.

Since Kotlin 1.5
fun assertContentEquals(expected: <Error class: unknown class>?, actual: <Error class: unknown class>?, message: String? = null)
fun assertContentEquals(expected: <Error class: unknown class>?, actual: <Error class: unknown class>?, message: String? = null)
fun assertContentEquals(expected: <Error class: unknown class>?, actual: <Error class: unknown class>?, message: String? = null)
fun assertContentEquals(expected: <Error class: unknown class>?, actual: <Error class: unknown class>?, message: String? = null)
fun <T> assertContentEquals(expected: Array<T>?, actual: Array<T>?, message: String? = null)
fun assertContentEquals(expected: BooleanArray?, actual: BooleanArray?, message: String? = null)
fun assertContentEquals(expected: ByteArray?, actual: ByteArray?, message: String? = null)
fun assertContentEquals(expected: CharArray?, actual: CharArray?, message: String? = null)
fun assertContentEquals(expected: DoubleArray?, actual: DoubleArray?, message: String? = null)
fun assertContentEquals(expected: FloatArray?, actual: FloatArray?, message: String? = null)
fun assertContentEquals(expected: IntArray?, actual: IntArray?, message: String? = null)
fun assertContentEquals(expected: LongArray?, actual: LongArray?, message: String? = null)
fun assertContentEquals(expected: ShortArray?, actual: ShortArray?, message: String? = null)

Asserts that the expected array is structurally equal to the actual array, with an optional message.

Since Kotlin 1.5
fun <T> assertContentEquals(expected: Iterable<T>?, actual: Iterable<T>?, message: String? = null)

Asserts that the expected iterable is structurally equal to the actual iterable, with an optional message.

Since Kotlin 1.5
fun <T> assertContentEquals(expected: Set<T>?, actual: Set<T>?, message: String? = null)
Since Kotlin 1.5
Link copied to clipboard
fun <T> assertEquals(expected: T, actual: T, message: String? = null)

Asserts that the expected value is equal to the actual value, with an optional message.

Since Kotlin 1.0
fun assertEquals(expected: Double, actual: Double, absoluteTolerance: Double, message: String? = null)
fun assertEquals(expected: Float, actual: Float, absoluteTolerance: Float, message: String? = null)

Asserts that the difference between the actual and the expected is within an absoluteTolerance, with an optional message.

Since Kotlin 1.5
Link copied to clipboard
inline fun assertFails(block: () -> Unit): Throwable

Asserts that given function block fails by throwing an exception.

Since Kotlin 1.0
inline fun assertFails(message: String?, block: () -> Unit): Throwable

Asserts that given function block fails by throwing an exception.

Since Kotlin 1.1
Link copied to clipboard
inline fun <T : Throwable> assertFailsWith(message: String? = null, block: () -> Unit): T

Asserts that a block fails with a specific exception of type T being thrown.

Since Kotlin 1.0
inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit): T
inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, message: String?, block: () -> Unit): T

Asserts that a block fails with a specific exception of type exceptionClass being thrown.

Since Kotlin 1.0
Link copied to clipboard
fun assertFalse(actual: Boolean, message: String? = null)

Asserts that the expression is false with an optional message.

Since Kotlin 1.0
inline fun assertFalse(message: String? = null, block: () -> Boolean)

Asserts that the given block returns false.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T> assertIs(value: Any?, message: String? = null): T

Asserts that value is of type T, with an optional message.

Since Kotlin 1.5
Link copied to clipboard
inline fun <T> assertIsNot(value: Any?, message: String? = null)

Asserts that value is not of type T, with an optional message.

Since Kotlin 1.5
Link copied to clipboard
fun <T> assertNotEquals(illegal: T, actual: T, message: String? = null)

Asserts that the actual value is not equal to the illegal value, with an optional message.

Since Kotlin 1.0
fun assertNotEquals(illegal: Double, actual: Double, absoluteTolerance: Double, message: String? = null)
fun assertNotEquals(illegal: Float, actual: Float, absoluteTolerance: Float, message: String? = null)

Asserts that the difference between the actual and the illegal is not within an absoluteTolerance, with an optional message.

Since Kotlin 1.5
Link copied to clipboard
fun <T : Any> assertNotNull(actual: T?, message: String? = null): T

Asserts that the actual value is not null, with an optional message.

Since Kotlin 1.0
inline fun <T : Any, R> assertNotNull(actual: T?, message: String? = null, block: (T) -> R)

Asserts that the actual value is not null, with an optional message and a function block to process the not-null value.

Since Kotlin 1.0
Link copied to clipboard
fun <T> assertNotSame(illegal: T, actual: T, message: String? = null)

Asserts that actual is not the same instance as illegal, with an optional message.

Since Kotlin 1.0
Link copied to clipboard
fun assertNull(actual: Any?, message: String? = null)

Asserts that the actual value is null, with an optional message.

Since Kotlin 1.0
Link copied to clipboard
fun <T> assertSame(expected: T, actual: T, message: String? = null)

Asserts that expected is the same instance as actual, with an optional message.

Since Kotlin 1.0
Link copied to clipboard
fun assertTrue(actual: Boolean, message: String? = null)

Asserts that the expression is true with an optional message.

Since Kotlin 1.0
inline fun assertTrue(message: String? = null, block: () -> Boolean)

Asserts that the given block returns true.

Since Kotlin 1.0
Link copied to clipboard

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.

Since Kotlin 1.0
Link copied to clipboard
inline fun <T> expect(expected: T, block: () -> T)

Asserts that given function block returns the given expected value.

Since Kotlin 1.0
inline fun <T> expect(expected: T, message: String?, block: () -> T)

Asserts that given function block returns the given expected value and use the given message if it fails.

Since Kotlin 1.0
Link copied to clipboard
fun fail(message: String? = null): Nothing

Marks a test as having failed if this point in the execution path is reached, with an optional message.

Since Kotlin 1.0
fun fail(message: String? = null, cause: Throwable? = null): Nothing

Marks a test as having failed if this point in the execution path is reached, with an optional message and cause exception.

Since Kotlin 1.4
Link copied to clipboard
expect fun todo(block: () -> Unit)

Takes the given block of test code and doesn't execute it.

Since Kotlin 1.0
actual fun todo(block: () -> Unit)

Takes the given block of test code and doesn't execute it.

Since Kotlin 1.1
actual inline fun todo(block: () -> Unit)

Takes the given block of test code and doesn't execute it.

Since Kotlin 1.0
actual inline fun todo(block: () -> Unit)

Takes the given block of test code and doesn't execute it.

Since Kotlin 1.3
actual fun todo(block: () -> Unit)

Takes the given block of test code and doesn't execute it.

Since Kotlin 1.8
actual fun todo(block: () -> Unit)

Takes the given block of test code and doesn't execute it.

Since Kotlin 1.8