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.

Types

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
actual typealias AfterTest = <Error class: unknown class>
Since Kotlin 1.0
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
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
expect annotation class BeforeTest

Marks a function to be invoked before each test.

Since Kotlin 1.0
actual typealias BeforeTest = <Error class: unknown class>
Since Kotlin 1.0
Link copied to clipboard

Default Asserter implementation to avoid dependency on JUnit or TestNG.

Since Kotlin 1.0
Link copied to clipboard
expect annotation class Ignore

Marks a test or a suite as ignored.

Since Kotlin 1.0
actual typealias Ignore = <Error class: unknown class>
Since Kotlin 1.0
Link copied to clipboard
@Target(allowedTargets = [AnnotationTarget.FUNCTION])
expect annotation class Test

Marks a function as a test.

Since Kotlin 1.0
actual typealias Test = <Error class: unknown class>
Since Kotlin 1.0

Properties

Link copied to clipboard

Current adapter providing assertion implementations

Since Kotlin 1.0

Functions

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
Link copied to clipboard
@JvmName(name = "assertFailsInline")
inline fun assertFails(block: () -> Unit): Throwable

Asserts that given function block fails by throwing an exception.

Since Kotlin 1.0
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
@JvmName(name = "assertFailsWithInline")
inline fun <T : Throwable> assertFailsWith(exceptionClass: KClass<T>, block: () -> Unit): T
@JvmName(name = "assertFailsWithInline")
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
@JvmName(name = "assertFalseInline")
inline fun assertFalse(message: String? = null, block: () -> Boolean)

Asserts that the given block returns false.

Since Kotlin 1.0
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
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
@JvmName(name = "assertNotNullInline")
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
@JvmName(name = "assertTrueInline")
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
@JvmName(name = "expectInline")
inline fun <T> expect(expected: T, block: () -> T)

Asserts that given function block returns the given expected value.

Since Kotlin 1.0
@JvmName(name = "expectInline")
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
Link copied to clipboard
expect inline fun todo(block: () -> Unit)

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

Since Kotlin 1.0