assertk / assertk.assertions

Package assertk.assertions

Functions

(common, jvm)

any

Asserts on each item in the iterable, passing if any of the items pass. The given lambda will be run for each item.

fun <E, T : Iterable<E>> Assert<T>.any(f: (Assert<E>) -> Unit): Unit
(common, jvm)

atLeast

Asserts on each item in the iterable, passing if at least times items pass. The given lambda will be run for each item.

fun <E, T : Iterable<E>> Assert<T>.atLeast(times: Int, f: (Assert<E>) -> Unit): Unit
(common, jvm)

atMost

Asserts on each item in the iterable, passing if at most times items pass. The given lambda will be run for each item.

fun <E, T : Iterable<E>> Assert<T>.atMost(times: Int, f: (Assert<E>) -> Unit): Unit
(jvm)

bytes

Returns an assert on the file's contents as bytes.

fun Assert<File>.bytes(): Assert<ByteArray>

Assert on file bytes

fun Assert<Path>.bytes(): Assert<ByteArray>
(common, jvm)

cause

Returns an assert on the throwable's cause.

fun Assert<Throwable>.cause(): Assert<Throwable?>
(common, jvm)

contains

Asserts the ByteArray contains the expected element, using in.

fun Assert<ByteArray>.contains(element: Byte): Unit

Asserts the IntArray contains the expected element, using in.

fun Assert<IntArray>.contains(element: Int): Unit

Asserts the ShortArray contains the expected element, using in.

fun Assert<ShortArray>.contains(element: Short): Unit

Asserts the LongArray contains the expected element, using in.

fun Assert<LongArray>.contains(element: Long): Unit

Asserts the FloatArray contains the expected element, using in.

fun Assert<FloatArray>.contains(element: Float): Unit

Asserts the DoubleArray contains the expected element, using in.

fun Assert<DoubleArray>.contains(element: Double): Unit

Asserts the CharArray contains the expected element, using in.

fun Assert<CharArray>.contains(element: Char): Unit

Asserts the array contains the expected element, using in.

fun Assert<Array<*>>.contains(element: Any?): Unit

Asserts the iterable contains the expected element, using in.

fun Assert<Iterable<*>>.contains(element: Any?): Unit

Asserts the map contains the expected key-value pair.

fun <K, V> Assert<Map<K, V>>.contains(key: K, value: V): Unit
fun <K, V> Assert<Map<K, V>>.contains(element: Pair<K, V>): Unit

Asserts the string contains the expected substring.

fun Assert<String>.contains(expected: CharSequence, ignoreCase: Boolean = false): Unit

Asserts the string contains the expected substring(s).

fun Assert<String>.contains(vararg expected: CharSequence, ignoreCase: Boolean = false): Unit

Asserts the string contains the expected strings.

fun Assert<String>.contains(expected: Iterable<CharSequence>, ignoreCase: Boolean = false): Unit
(common, jvm)

containsAll

Asserts the ByteArray contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<ByteArray>.containsAll(vararg elements: Byte): Unit

Asserts the IntArray contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<IntArray>.containsAll(vararg elements: Int): Unit

Asserts the ShortArray contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<ShortArray>.containsAll(vararg elements: Short): Unit

Asserts the LongArray contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<LongArray>.containsAll(vararg elements: Long): Unit

Asserts the FloatArray contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<FloatArray>.containsAll(vararg elements: Float): Unit

Asserts the DoubleArray contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<DoubleArray>.containsAll(vararg elements: Double): Unit

Asserts the CharArray contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<CharArray>.containsAll(vararg elements: Char): Unit

Asserts the array contains all the expected elements, in any order. The array may also contain additional elements.

fun Assert<Array<*>>.containsAll(vararg elements: Any?): Unit

Asserts the collection contains all the expected elements, in any order. The collection may also contain additional elements.

fun Assert<Iterable<*>>.containsAll(vararg elements: Any?): Unit

Asserts the map contains all the expected elements. The map may also contain additional elements.

fun <K, V> Assert<Map<K, V>>.containsAll(vararg elements: Pair<K, V>): Unit
(common, jvm)

containsExactly

Asserts the ByteArray contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<ByteArray>.containsExactly(vararg elements: Byte): Unit

Asserts the IntArray contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<IntArray>.containsExactly(vararg elements: Int): Unit

Asserts the ShortArray contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<ShortArray>.containsExactly(vararg elements: Short): Unit

Asserts the LongArray contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<LongArray>.containsExactly(vararg elements: Long): Unit

Asserts the FloatArray contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<FloatArray>.containsExactly(vararg elements: Float): Unit

Asserts the DoubleArray contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<DoubleArray>.containsExactly(vararg elements: Double): Unit

Asserts the CharArray contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<CharArray>.containsExactly(vararg elements: Char): Unit

Asserts the array contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<Array<*>>.containsExactly(vararg elements: Any?): Unit

Asserts the list contains exactly the expected elements. They must be in the same order and there must not be any extra elements.

fun Assert<List<*>>.containsExactly(vararg elements: Any?): Unit
(common, jvm)

containsNone

Asserts the ByteArray does not contain any of the expected elements.

fun Assert<ByteArray>.containsNone(vararg elements: Byte): Unit

Asserts the IntArray does not contain any of the expected elements.

fun Assert<IntArray>.containsNone(vararg elements: Int): Unit

Asserts the ShortArray does not contain any of the expected elements.

fun Assert<ShortArray>.containsNone(vararg elements: Short): Unit

Asserts the LongArray does not contain any of the expected elements.

fun Assert<LongArray>.containsNone(vararg elements: Long): Unit

Asserts the FloatArray does not contain any of the expected elements.

fun Assert<FloatArray>.containsNone(vararg elements: Float): Unit

Asserts the DoubleArray does not contain any of the expected elements.

fun Assert<DoubleArray>.containsNone(vararg elements: Double): Unit

Asserts the CharArray does not contain any of the expected elements.

fun Assert<CharArray>.containsNone(vararg elements: Char): Unit

Asserts the collection does not contain any of the expected elements.

fun Assert<Array<*>>.containsNone(vararg elements: Any?): Unit
fun Assert<Iterable<*>>.containsNone(vararg elements: Any?): Unit

Asserts the map does not contain any of the expected elements.

fun <K, V> Assert<Map<K, V>>.containsNone(vararg elements: Pair<K, V>): Unit
(common, jvm)

containsOnly

Asserts the ByteArray contains only the expected elements, in any order.

fun Assert<ByteArray>.containsOnly(vararg elements: Byte): Unit

Asserts the IntArray contains only the expected elements, in any order.

fun Assert<IntArray>.containsOnly(vararg elements: Int): Unit

Asserts the ShortArray contains only the expected elements, in any order.

fun Assert<ShortArray>.containsOnly(vararg elements: Short): Unit

Asserts the LongArray contains only the expected elements, in any order.

fun Assert<LongArray>.containsOnly(vararg elements: Long): Unit

Asserts the FloatArray contains only the expected elements, in any order.

fun Assert<FloatArray>.containsOnly(vararg elements: Float): Unit

Asserts the DoubleArray contains only the expected elements, in any order.

fun Assert<DoubleArray>.containsOnly(vararg elements: Double): Unit

Asserts the CharArray contains only the expected elements, in any order.

fun Assert<CharArray>.containsOnly(vararg elements: Char): Unit

Asserts the array contains only the expected elements, in any order.

fun Assert<Array<*>>.containsOnly(vararg elements: Any?): Unit

Asserts the collection contains only the expected elements, in any order.

fun Assert<Iterable<*>>.containsOnly(vararg elements: Any?): Unit

Asserts the map contains only the expected elements. There must not be any extra elements.

fun <K, V> Assert<Map<K, V>>.containsOnly(vararg elements: Pair<K, V>): Unit
(common, jvm)

corresponds

Asserts the value corresponds to the expected one using the given correspondence function to compare them. This is useful when the objects don't have an equals implementation.

fun <T, E> Assert<T>.corresponds(expected: E, correspondence: (T, E) -> Boolean): Unit
(common, jvm)

doesNotContain

Asserts the ByteArray does not contain the expected element, using !in.

fun Assert<ByteArray>.doesNotContain(element: Byte): Unit

Asserts the IntArray does not contain the expected element, using !in.

fun Assert<IntArray>.doesNotContain(element: Int): Unit

Asserts the ShortArray does not contain the expected element, using !in.

fun Assert<ShortArray>.doesNotContain(element: Short): Unit

Asserts the LongArray does not contain the expected element, using !in.

fun Assert<LongArray>.doesNotContain(element: Long): Unit

Asserts the FloatArray does not contain the expected element, using !in.

fun Assert<FloatArray>.doesNotContain(element: Float): Unit

Asserts the DoubleArray does not contain the expected element, using !in.

fun Assert<DoubleArray>.doesNotContain(element: Double): Unit

Asserts the CharArray does not contain the expected element, using !in.

fun Assert<CharArray>.doesNotContain(element: Char): Unit

Asserts the array does not contain the expected element, using !in.

fun Assert<Array<*>>.doesNotContain(element: Any?): Unit

Asserts the iterable does not contain the expected element, using !in.

fun Assert<Iterable<*>>.doesNotContain(element: Any?): Unit

Asserts the map does not contain the expected key-value pair.

fun <K, V> Assert<Map<K, V>>.doesNotContain(key: K, value: V): Unit
fun <K, V> Assert<Map<K, V>>.doesNotContain(element: Pair<K, V>): Unit

Asserts the string does not contain the specified string.

fun Assert<String>.doesNotContain(expected: CharSequence, ignoreCase: Boolean = false): Unit

Asserts the string does not contain the specified string(s).

fun Assert<String>.doesNotContain(vararg expected: CharSequence, ignoreCase: Boolean = false): Unit

Asserts the string does not contain the specified strings.

fun Assert<String>.doesNotContain(expected: Iterable<CharSequence>, ignoreCase: Boolean = false): Unit
(common, jvm)

doesNotCorrespond

Asserts the value does not correspond to the expected one using the given correspondence function to compare them. This is useful when the objects don't have an equals implementation.

fun <T, E> Assert<T>.doesNotCorrespond(expected: E, correspondence: (T, E) -> Boolean): Unit

doesNotHaveClass

(jvm)

Asserts the value does not have the expected java class. This is an exact match, so assertThat("test").doesNotHaveClass(String::class.java) is fails but assertThat("test").doesNotHaveClass(Any::class.java) is successful.

fun <T : Any> Assert<T>.doesNotHaveClass(jclass: Class<out T>): Unit(common, jvm)

Asserts the value does not have the expected kotlin class. This is an exact match, so assertThat("test").doesNotHaveClass(String::class) is fails but assertThat("test").doesNotHaveClass(Any::class) is successful.

fun <T : Any> Assert<T>.doesNotHaveClass(kclass: KClass<out T>): Unit
(common, jvm)

each

Asserts on each item in the ByteArray. The given lambda will be run for each item.

fun Assert<ByteArray>.each(f: (Assert<Byte>) -> Unit): Unit

Asserts on each item in the IntArray. The given lambda will be run for each item.

fun Assert<IntArray>.each(f: (Assert<Int>) -> Unit): Unit

Asserts on each item in the ShortArray. The given lambda will be run for each item.

fun Assert<ShortArray>.each(f: (Assert<Short>) -> Unit): Unit

Asserts on each item in the LongArray. The given lambda will be run for each item.

fun Assert<LongArray>.each(f: (Assert<Long>) -> Unit): Unit

Asserts on each item in the FloatArray. The given lambda will be run for each item.

fun Assert<FloatArray>.each(f: (Assert<Float>) -> Unit): Unit

Asserts on each item in the DoubleArray. The given lambda will be run for each item.

fun Assert<DoubleArray>.each(f: (Assert<Double>) -> Unit): Unit

Asserts on each item in the CharArray. The given lambda will be run for each item.

fun Assert<CharArray>.each(f: (Assert<Char>) -> Unit): Unit

Asserts on each item in the array. The given lambda will be run for each item.

fun <T> Assert<Array<T>>.each(f: (Assert<T>) -> Unit): Unit

Asserts on each item in the iterable. The given lambda will be run for each item.

fun <E> Assert<Iterable<E>>.each(f: (Assert<E>) -> Unit): Unit
(common, jvm)

endsWith

Asserts the string ends with the expected string.

fun Assert<String>.endsWith(other: String, ignoreCase: Boolean = false): Unit
(common, jvm)

exactly

Asserts on each item in the iterable, passing if exactly times items pass. The given lambda will be run for each item.

fun <E, T : Iterable<E>> Assert<T>.exactly(times: Int, f: (Assert<E>) -> Unit): Unit
(jvm)

exists

Asserts the file exists.

fun Assert<File>.exists(): Unit
(jvm)

extension

Returns an assert on the file's extension.

fun Assert<File>.extension(): Assert<String>
(common, jvm)

extracting

Extracts a value of from each item in the array, allowing you to assert on a list of those values.

fun <E, R> Assert<Array<E>>.extracting(f1: (E) -> R): Assert<List<R>>

Extracts two values of from each item in the array, allowing you to assert on a list of paris of those values.

fun <E, R1, R2> Assert<Array<E>>.extracting(f1: (E) -> R1, f2: (E) -> R2): Assert<List<Pair<R1, R2>>>

Extracts three values from each item in the array, allowing you to assert on a list of triples of those values.

fun <E, R1, R2, R3> Assert<Array<E>>.extracting(f1: (E) -> R1, f2: (E) -> R2, f3: (E) -> R3): Assert<List<Triple<R1, R2, R3>>>

Extracts a value of from each item in the iterable, allowing you to assert on a list of those values.

fun <E, R> Assert<Iterable<E>>.extracting(f1: (E) -> R): Assert<List<R>>

Extracts two values of from each item in the iterable, allowing you to assert on a list of paris of those values.

fun <E, R1, R2> Assert<Iterable<E>>.extracting(f1: (E) -> R1, f2: (E) -> R2): Assert<List<Pair<R1, R2>>>

Extracts three values from each item in the iterable, allowing you to assert on a list of triples of those values.

fun <E, R1, R2, R3> Assert<Iterable<E>>.extracting(f1: (E) -> R1, f2: (E) -> R2, f3: (E) -> R3): Assert<List<Triple<R1, R2, R3>>>
(common, jvm)

hasCause

Asserts the throwable is similar to the expected cause, checking the type and message.

fun Assert<Throwable>.hasCause(cause: Throwable): Unit

hasClass

(jvm)

Asserts the value has the expected java class. This is an exact match, so assertThat("test").hasClass(String::class.java) is successful but assertThat("test").hasClass(Any::class.java) fails.

fun <T : Any> Assert<T>.hasClass(jclass: Class<out T>): Unit(common, jvm)

Asserts the value has the expected kotlin class. This is an exact match, so assertThat("test").hasClass(String::class) is successful but assertThat("test").hasClass(Any::class) fails.

fun <T : Any> Assert<T>.hasClass(kclass: KClass<out T>): Unit
(jvm)

hasDirectChild

Asserts the file has the expected direct child.

fun Assert<File>.hasDirectChild(expected: File): Unit
(jvm)

hasExtension

Asserts the file has the expected extension.

fun Assert<File>.hasExtension(expected: String): Unit
(common, jvm)

hasHashCode

Asserts the value has the expected hash code from it's hashCode.

fun Assert<Any>.hasHashCode(hashCode: Int): Unit
(common, jvm)

hashCodeFun

Returns an assert on the hasCode method of the value.

fun Assert<Any>.hashCodeFun(): Assert<Int>
(common, jvm)

hasLength

Asserts the char sequence has the expected length.

fun Assert<CharSequence>.hasLength(length: Int): Unit
(common, jvm)

hasLineCount

Asserts the string has the expected number of lines.

fun Assert<String>.hasLineCount(lineCount: Int): Unit
(common, jvm)

hasMessage

Asserts the throwable has the expected message.

fun Assert<Throwable>.hasMessage(message: String?): Unit
(jvm)

hasName

Asserts the file has the expected name.

fun Assert<File>.hasName(expected: String): Unit
(common, jvm)

hasNoCause

Asserts the throwable has no cause.

fun Assert<Throwable>.hasNoCause(): Unit
(jvm)

hasNotSameContentAs

Asserts that the actual stream has a different content as the expected stream. Both InputStreams will be closed by the assertion.

fun Assert<InputStream>.hasNotSameContentAs(expected: InputStream): Unit
(jvm)

hasParent

Asserts the file has the expected parent path.

fun Assert<File>.hasParent(expected: String): Unit
(jvm)

hasPath

Asserts the file has the expected path.

fun Assert<File>.hasPath(expected: String): Unit
(common, jvm)

hasRootCause

Asserts the throwable is similar to the expected root cause, checking the type and message.

fun Assert<Throwable>.hasRootCause(cause: Throwable): Unit
(jvm)

hasSameContentAs

Asserts that the actual stream has the same content as the expected stream. Both InputStreams will be closed by the assertion.

fun Assert<InputStream>.hasSameContentAs(expected: InputStream): Unit
(common, jvm)

hasSameLengthAs

Asserts the char sequence has the same length as the expected one.

fun Assert<CharSequence>.hasSameLengthAs(other: CharSequence): Unit
(common, jvm)

hasSameSizeAs

Asserts the ByteArray has the same size as the expected array.

fun Assert<ByteArray>.hasSameSizeAs(other: ByteArray): Unit

Asserts the IntArray has the same size as the expected array.

fun Assert<IntArray>.hasSameSizeAs(other: IntArray): Unit

Asserts the ShortArray has the same size as the expected array.

fun Assert<ShortArray>.hasSameSizeAs(other: ShortArray): Unit

Asserts the LongArray has the same size as the expected array.

fun Assert<LongArray>.hasSameSizeAs(other: LongArray): Unit

Asserts the FloatArray has the same size as the expected array.

fun Assert<FloatArray>.hasSameSizeAs(other: FloatArray): Unit

Asserts the DoubleArray has the same size as the expected array.

fun Assert<DoubleArray>.hasSameSizeAs(other: DoubleArray): Unit

Asserts the CharArray has the same size as the expected array.

fun Assert<CharArray>.hasSameSizeAs(other: CharArray): Unit

Asserts the array has the same size as the expected array.

fun Assert<Array<*>>.hasSameSizeAs(other: Array<*>): Unit

Asserts the collection has the same size as the expected collection.

fun Assert<Collection<*>>.hasSameSizeAs(other: Collection<*>): Unit

Asserts the map has the same size as the expected map.

fun Assert<Map<*, *>>.hasSameSizeAs(other: Map<*, *>): Unit
(common, jvm)

hasSize

Asserts the ByteArray has the expected size.

fun Assert<ByteArray>.hasSize(size: Int): Unit

Asserts the IntArray has the expected size.

fun Assert<IntArray>.hasSize(size: Int): Unit

Asserts the ShortArray has the expected size.

fun Assert<ShortArray>.hasSize(size: Int): Unit

Asserts the LongArray has the expected size.

fun Assert<LongArray>.hasSize(size: Int): Unit

Asserts the FloatArray has the expected size.

fun Assert<FloatArray>.hasSize(size: Int): Unit

Asserts the DoubleArray has the expected size.

fun Assert<DoubleArray>.hasSize(size: Int): Unit

Asserts the CharArray has the expected size.

fun Assert<CharArray>.hasSize(size: Int): Unit

Asserts the array has the expected size.

fun Assert<Array<*>>.hasSize(size: Int): Unit

Asserts the collection has the expected size.

fun Assert<Collection<*>>.hasSize(size: Int): Unit
fun Assert<Map<*, *>>.hasSize(size: Int): Unit
(jvm)

hasText

Asserts the file contains exactly the expected text (and nothing else).

fun Assert<File>.hasText(expected: String, charset: Charset = Charsets.UTF_8): Unit
(common, jvm)

hasToString

Asserts the value has the expected string from it's toString.

fun Assert<Any?>.hasToString(string: String): Unit
(common, jvm)

index

Returns an assert that assertion on the value at the given index in the array.

fun Assert<ByteArray>.index(index: Int): Assert<Byte>
fun Assert<IntArray>.index(index: Int): Assert<Int>
fun Assert<ShortArray>.index(index: Int): Assert<Short>
fun Assert<LongArray>.index(index: Int): Assert<Long>
fun Assert<FloatArray>.index(index: Int): Assert<Float>
fun Assert<DoubleArray>.index(index: Int): Assert<Double>
fun Assert<CharArray>.index(index: Int): Assert<Char>
fun <T> Assert<Array<T>>.index(index: Int): Assert<T>

Returns an assert that assertion on the value at the given index in the list.

fun <T> Assert<List<T>>.index(index: Int): Assert<T>
(common, jvm)

isBetween

Asserts the value is between the expected start and end values, inclusive.

fun <A, B : Comparable<A>> Assert<B>.isBetween(start: A, end: A): Unit
(common, jvm)

isCloseTo

Asserts the value if it is close to the expected value with given delta.

fun Assert<Float>.isCloseTo(value: Float, delta: Float): Unit
fun Assert<Double>.isCloseTo(value: Double, delta: Double): Unit
(jvm)

isDataClassEqualTo

Like isEqualTo but reports exactly which properties differ. Only supports data classes. Note: you should not use this if your data class has a custom Any.equals since it can be misleading.

fun <T : Any> Assert<T>.isDataClassEqualTo(expected: T): Unit
(jvm)

isDirectory

Asserts the file is a directory.

fun Assert<File>.isDirectory(): Unit

Assert that the path is a directory.

fun Assert<Path>.isDirectory(vararg options: LinkOption): Unit
(common, jvm)

isEmpty

Asserts the ByteArray is empty.

fun Assert<ByteArray>.isEmpty(): Unit

Asserts the IntArray is empty.

fun Assert<IntArray>.isEmpty(): Unit

Asserts the ShortArray is empty.

fun Assert<ShortArray>.isEmpty(): Unit

Asserts the LongArray is empty.

fun Assert<LongArray>.isEmpty(): Unit

Asserts the FloatArray is empty.

fun Assert<FloatArray>.isEmpty(): Unit

Asserts the DoubleArray is empty.

fun Assert<DoubleArray>.isEmpty(): Unit

Asserts the CharArray is empty.

fun Assert<CharArray>.isEmpty(): Unit

Asserts the array is empty.

fun Assert<Array<*>>.isEmpty(): Unit

Asserts the char sequence is empty.

fun Assert<CharSequence>.isEmpty(): Unit

Asserts the collection is empty.

fun Assert<Collection<*>>.isEmpty(): Unit
fun Assert<Map<*, *>>.isEmpty(): Unit

Asserts the iterable is empty.

fun Assert<Iterable<*>>.isEmpty(): Unit

isEqualByComparingTo

(jvm)

Asserts that actual.compareTo(BigDecimal(expected) == 0.

fun Assert<BigDecimal>.isEqualByComparingTo(expected: String): Unit(common, jvm)

Asserts that value is equal when comparing using {@link Comparable#compareTo(Object)}.

fun <T : Comparable<T>> Assert<T>.isEqualByComparingTo(expected: T): Unit
(common, jvm)

isEqualTo

Asserts the ByteArray contents are equal to the expected one, using contentDeepEquals.

fun Assert<ByteArray>.isEqualTo(expected: ByteArray): Unit

Asserts the IntArray contents are equal to the expected one, using contentDeepEquals.

fun Assert<IntArray>.isEqualTo(expected: IntArray): Unit

Asserts the ShortArray contents are equal to the expected one, using contentDeepEquals.

fun Assert<ShortArray>.isEqualTo(expected: ShortArray): Unit

Asserts the LongArray contents are equal to the expected one, using contentDeepEquals.

fun Assert<LongArray>.isEqualTo(expected: LongArray): Unit

Asserts the FloatArray contents are equal to the expected one, using contentDeepEquals.

fun Assert<FloatArray>.isEqualTo(expected: FloatArray): Unit

Asserts the DoubleArray contents are equal to the expected one, using contentDeepEquals.

fun Assert<DoubleArray>.isEqualTo(expected: DoubleArray): Unit

Asserts the CharArray contents are equal to the expected one, using contentDeepEquals.

fun Assert<CharArray>.isEqualTo(expected: CharArray): Unit

Asserts the value is equal to the expected one, using ==.

fun <T> Assert<T>.isEqualTo(expected: T): Unit

Asserts the array contents are equal to the expected one, using contentDeepEquals.

fun <T> Assert<Array<T>>.isEqualTo(expected: Array<T>): Unit

Asserts the string is equal to the expected string.

fun Assert<String?>.isEqualTo(other: String?, ignoreCase: Boolean = false): Unit
(jvm)

isEqualToIgnoringGivenProperties

Returns an assert that compares for all properties except the given properties on the calling class

fun <T : Any> Assert<T>.isEqualToIgnoringGivenProperties(other: T, vararg properties: KProperty1<T, Any?>): Unit
(common, jvm)

isEqualToWithGivenProperties

Returns an assert that compares only the given properties on the calling class

fun <T> Assert<T>.isEqualToWithGivenProperties(other: T, vararg properties: KProperty1<T, Any?>): Unit
(jvm)

isExecutable

Assert that the path is an executable.

fun Assert<Path>.isExecutable(): Unit
(common, jvm)

isFailure

Asserts the given assertk.Result threw an exception, returning that exception if it was or failing it if didn't.

fun <T> Assert<Result<T>>.isFailure(): Assert<Throwable>
(common, jvm)

isFalse

Asserts the boolean is false.

fun Assert<Boolean>.isFalse(): Unit
(jvm)

isFile

Asserts the file is a simple file (not a directory).

fun Assert<File>.isFile(): Unit
(common, jvm)

isGreaterThan

Asserts the value is greater than the expected value, using >.

fun <A, B : Comparable<A>> Assert<B>.isGreaterThan(other: A): Unit
(common, jvm)

isGreaterThanOrEqualTo

Asserts the value is greater or equal to the expected value, using >=.

fun <A, B : Comparable<A>> Assert<B>.isGreaterThanOrEqualTo(other: A): Unit
(jvm)

isHidden

Asserts the file is hidden.

fun Assert<File>.isHidden(): Unit

Assert that the path is hidden.

fun Assert<Path>.isHidden(): Unit
(common, jvm)

isIn

Asserts the value is in the expected values, using in.

fun <T> Assert<T>.isIn(vararg values: T): Unit

isInstanceOf

(jvm)

Asserts the value is an instance of the expected java class. Both assertThat("test").isInstanceOf(String::class.java) and assertThat("test").isInstanceOf(Any::class.java) is successful.

fun <T : Any, S : T> Assert<T>.isInstanceOf(jclass: Class<S>): Assert<S>(common, jvm)

Asserts the value is an instance of the expected kotlin class. Both assertThat("test").isInstanceOf(String::class) and assertThat("test").isInstanceOf(Any::class) is successful.

fun <T : Any, S : T> Assert<T>.isInstanceOf(kclass: KClass<S>): Assert<S>
(common, jvm)

isLessThan

Asserts the value is less than the expected value, using <.

fun <A, B : Comparable<A>> Assert<B>.isLessThan(other: A): Unit
(common, jvm)

isLessThanOrEqualTo

Asserts the value is less than or equal to the expected value, using <=.

fun <A, B : Comparable<A>> Assert<B>.isLessThanOrEqualTo(other: A): Unit
(common, jvm)

isNegative

Asserts the number is less than 0.

fun Assert<Number>.isNegative(): Unit
(common, jvm)

isNotEmpty

Asserts the ByteArray is not empty.

fun Assert<ByteArray>.isNotEmpty(): Unit

Asserts the IntArray is not empty.

fun Assert<IntArray>.isNotEmpty(): Unit

Asserts the ShortArray is not empty.

fun Assert<ShortArray>.isNotEmpty(): Unit

Asserts the LongArray is not empty.

fun Assert<LongArray>.isNotEmpty(): Unit

Asserts the FloatArray is not empty.

fun Assert<FloatArray>.isNotEmpty(): Unit

Asserts the DoubleArray is not empty.

fun Assert<DoubleArray>.isNotEmpty(): Unit

Asserts the CharArray is not empty.

fun Assert<CharArray>.isNotEmpty(): Unit

Asserts the array is not empty.

fun Assert<Array<*>>.isNotEmpty(): Unit

Asserts the char sequence is not empty.

fun Assert<CharSequence>.isNotEmpty(): Unit

Asserts the collection is not empty.

fun Assert<Collection<*>>.isNotEmpty(): Unit
fun Assert<Map<*, *>>.isNotEmpty(): Unit

Asserts the iterable is not empty.

fun Assert<Iterable<*>>.isNotEmpty(): Unit
(common, jvm)

isNotEqualTo

Asserts the ByteArray contents are not equal to the expected one, using contentDeepEquals.

fun Assert<ByteArray>.isNotEqualTo(expected: ByteArray): Unit

Asserts the IntArray contents are not equal to the expected one, using contentDeepEquals.

fun Assert<IntArray>.isNotEqualTo(expected: IntArray): Unit

Asserts the ShortArray contents are not equal to the expected one, using contentDeepEquals.

fun Assert<ShortArray>.isNotEqualTo(expected: ShortArray): Unit

Asserts the LongArray contents are not equal to the expected one, using contentDeepEquals.

fun Assert<LongArray>.isNotEqualTo(expected: LongArray): Unit

Asserts the FloatArray contents are not equal to the expected one, using contentDeepEquals.

fun Assert<FloatArray>.isNotEqualTo(expected: FloatArray): Unit

Asserts the DoubleArray contents are not equal to the expected one, using contentDeepEquals.

fun Assert<DoubleArray>.isNotEqualTo(expected: DoubleArray): Unit

Asserts the CharArray contents are not equal to the expected one, using contentDeepEquals.

fun Assert<CharArray>.isNotEqualTo(expected: CharArray): Unit

Asserts the value is not equal to the expected one, using !=.

fun Assert<Any?>.isNotEqualTo(expected: Any?): Unit

Asserts the array contents are not equal to the expected one, using contentDeepEquals.

fun <T> Assert<Array<T>>.isNotEqualTo(expected: Array<T>): Unit

Asserts the string is not equal to the expected string.

fun Assert<String?>.isNotEqualTo(other: String?, ignoreCase: Boolean = false): Unit
(jvm)

isNotHidden

Asserts the file is not hidden.

fun Assert<File>.isNotHidden(): Unit
(common, jvm)

isNotIn

Asserts the value is not in the expected values, using !in.

fun <T> Assert<T>.isNotIn(vararg values: T): Unit

isNotInstanceOf

(jvm)

Asserts the value is not an instance of the expected java class. Both assertThat("test").isNotInstanceOf(String::class) and assertThat("test").isNotInstanceOf(Any::class) fails.

fun <T : Any> Assert<T>.isNotInstanceOf(jclass: Class<out T>): Unit(common, jvm)

Asserts the value is not an instance of the expected kotlin class. Both assertThat("test").isNotInstanceOf(String::class) and assertThat("test").isNotInstanceOf(Any::class) fails.

fun <T : Any> Assert<T>.isNotInstanceOf(kclass: KClass<out T>): Unit
(common, jvm)

isNotNull

Asserts the value is not null. You can pass in an optional lambda to run additional assertions on the non-null value.

fun <T : Any> Assert<T?>.isNotNull(): Assert<T>
(common, jvm)

isNotSameAs

Asserts the value is not the same as the expected one, using !==.

fun Assert<Any?>.isNotSameAs(expected: Any?): Unit
(common, jvm)

isNotZero

Asserts the number is not 0.

fun Assert<Number>.isNotZero(): Unit
(common, jvm)

isNull

Asserts the value is null.

fun Assert<Any?>.isNull(): Unit
(common, jvm)

isNullOrEmpty

Asserts the ByteArray is null or empty.

fun Assert<ByteArray?>.isNullOrEmpty(): Unit

Asserts the IntArray is null or empty.

fun Assert<IntArray?>.isNullOrEmpty(): Unit

Asserts the ShortArray is null or empty.

fun Assert<ShortArray?>.isNullOrEmpty(): Unit

Asserts the LongArray is null or empty.

fun Assert<LongArray?>.isNullOrEmpty(): Unit

Asserts the FloatArray is null or empty.

fun Assert<FloatArray?>.isNullOrEmpty(): Unit

Asserts the DoubleArray is null or empty.

fun Assert<DoubleArray?>.isNullOrEmpty(): Unit

Asserts the CharArray is null or empty.

fun Assert<CharArray?>.isNullOrEmpty(): Unit

Asserts the array is null or empty.

fun Assert<Array<*>?>.isNullOrEmpty(): Unit

Asserts the char sequence is null or empty.

fun Assert<CharSequence?>.isNullOrEmpty(): Unit

Asserts the collection is null or empty.

fun Assert<Collection<*>?>.isNullOrEmpty(): Unit
fun Assert<Map<*, *>?>.isNullOrEmpty(): Unit
(common, jvm)

isPositive

Asserts the number is greater than 0.

fun Assert<Number>.isPositive(): Unit
(jvm)

isReadable

Assert that the path is readable.

fun Assert<Path>.isReadable(): Unit
(jvm)

isRegularFile

Assert that the path is a regular file.

fun Assert<Path>.isRegularFile(vararg options: LinkOption): Unit
(common, jvm)

isSameAs

Asserts the value is the same as the expected one, using ===.

fun <T> Assert<T>.isSameAs(expected: T): Unit
(jvm)

isSameFileAs

Assert that the path points to the same object as the other path.

fun Assert<Path>.isSameFileAs(expected: Path): Unit
(common, jvm)

isStrictlyBetween

Asserts the value is between the expected start and end values, non-inclusive.

fun <A, B : Comparable<A>> Assert<B>.isStrictlyBetween(start: A, end: A): Unit
(common, jvm)

isSuccess

Asserts the given assertk.Result successful returned a value, returning it's result if it did or failing if it didn't.

fun <T> Assert<Result<T>>.isSuccess(): Assert<T>
(jvm)

isSymbolicLink

Assert that the path is a symbolic link.

fun Assert<Path>.isSymbolicLink(): Unit
(common, jvm)

isTrue

Asserts the boolean is true.

fun Assert<Boolean>.isTrue(): Unit
(jvm)

isWritable

Assert that the path is writable link.

fun Assert<Path>.isWritable(): Unit
(common, jvm)

isZero

Asserts the number is 0.

fun Assert<Number>.isZero(): Unit
(jvm)

jClass

Returns an assert on the java class of the value.

fun <T : Any> Assert<T>.jClass(): Assert<Class<out T>>
(common, jvm)

kClass

Returns an assert on the kotlin class of the value.

fun Assert<Any>.kClass(): Assert<KClass<out Any>>
(common, jvm)

key

Returns an assert that asserts on the value at the given key in the map.

fun <K, V> Assert<Map<K, V>>.key(key: K): Assert<V>
(common, jvm)

length

Returns an assert on the CharSequence's length.

fun Assert<CharSequence>.length(): Assert<Int>
(jvm)

lines

Assert on file lines

fun Assert<Path>.lines(charset: Charset = Charsets.UTF_8): Assert<List<String>>
(common, jvm)

matches

Asserts the string matches the expected regular expression.

fun Assert<String>.matches(regex: Regex): Unit
(common, jvm)

matchesPredicate

Asserts if the values satisfies the predicate provided.

fun <T> Assert<T>.matchesPredicate(f: (T) -> Boolean): Unit
(common, jvm)

message

Returns an assert on the throwable's message.

fun Assert<Throwable>.message(): Assert<String?>
(common, jvm)

messageContains

Asserts the throwable contains the expected text

fun Assert<Throwable>.messageContains(text: String): Unit
(jvm)

name

Returns an assert on the file's name.

fun Assert<File>.name(): Assert<String!>
(common, jvm)

none

Asserts on each item in the iterable, passing if none of the items pass. The given lambda will be run for each item.

fun <E> Assert<Iterable<E>>.none(f: (Assert<E>) -> Unit): Unit
(jvm)

parent

Returns an assert on the file's parent.

fun Assert<File>.parent(): Assert<String!>
(jvm)

path

Returns an assert on the file's path.

fun Assert<File>.path(): Assert<String!>

prop

(jvm)

Returns an assert that asserts on the given property.

fun <T, P> Assert<T>.prop(callable: KCallable<P>): Assert<P>(common, jvm)

Returns an assert that asserts on the given property of the value.

fun <T, P> Assert<T>.prop(name: String, extract: (T) -> P): Assert<P>
(common, jvm)

rootCause

Returns an assert on the throwable's root cause.

fun Assert<Throwable>.rootCause(): Assert<Throwable>
(common, jvm)

size

Returns an assert on the ByteArray's size.

fun Assert<ByteArray>.size(): Assert<Int>

Returns an assert on the IntArray's size.

fun Assert<IntArray>.size(): Assert<Int>

Returns an assert on the ShortArray's size.

fun Assert<ShortArray>.size(): Assert<Int>

Returns an assert on the LongArray's size.

fun Assert<LongArray>.size(): Assert<Int>

Returns an assert on the FloatArray's size.

fun Assert<FloatArray>.size(): Assert<Int>

Returns an assert on the DoubleArray's size.

fun Assert<DoubleArray>.size(): Assert<Int>

Returns an assert on the CharArray's size.

fun Assert<CharArray>.size(): Assert<Int>

Returns an assert on the Arrays's size.

fun Assert<Array<*>>.size(): Assert<Int>

Returns an assert on the Collection's size.

fun Assert<Collection<*>>.size(): Assert<Int>

Returns an assert on the Maps's size.

fun Assert<Map<*, *>>.size(): Assert<Int>
(jvm)

stackTrace

Returns an assert on the throwable's stack trace.

fun Assert<Throwable>.stackTrace(): Assert<List<String>>
(common, jvm)

startsWith

Asserts the string starts with the expected string.

fun Assert<String>.startsWith(other: String, ignoreCase: Boolean = false): Unit
(jvm)

text

Returns an assert on the file's contents as text.

fun Assert<File>.text(charset: Charset = Charsets.UTF_8): Assert<String>
(common, jvm)

toStringFun

Returns an assert on the toString method of the value.

fun Assert<Any?>.toStringFun(): Assert<String>