kotest-core / io.kotest.core.test / Description

Description

data class Description

The description gives the full path to a TestCase.

It contains the name of every parent, with the root at index 0. And it includes the name of the test case it represents.

This is useful when you want to write generic extensions and you need to be able to filter on certain tests only.

Parameters

parents - each parent test case

name - the name of this test case

Constructors

<init>

The description gives the full path to a TestCase.

Description(parents: List<String>, name: String)

Properties

name

the name of this test case

val name: String

parents

each parent test case

val parents: List<String>

Functions

append

fun append(name: String): Description

depth

fun depth(): Int

fullName

fun fullName(): String

hasParent

fun hasParent(description: Description): Boolean

id

Returns a String version of this description, which is the parents + this name concatenated with slashes.

fun id(): String

isAncestorOf

Returns true if this instance is an ancestor (nth-parent) of the supplied argument.

fun isAncestorOf(description: Description): Boolean

isDescendentOf

Returns true if this description is the same as or a child, grandchild, etc of the given description.

fun isDescendentOf(description: Description): Boolean

isOnPath

Returns true if this instance is on the path to the given descripton. That is, if this instance is either an ancestor of, of the same as, the given description.

fun isOnPath(description: Description): Boolean

isParentOf

Returns true if this instance is the immediate parent of the supplied argument.

fun isParentOf(description: Description): Boolean

isSpec

fun isSpec(): Boolean

isTopLevel

Returns true if this test is a top level test. In other words, if the test has no parents other than the spec itself.

fun isTopLevel(): Boolean

names

fun names(): List<String>

parent

Returns the parent of this description, unless it is a spec then it will throw

fun parent(): Description

spec

fun spec(): Description

tail

fun tail(): Description

Companion Object Functions

spec

Creates a Spec level description object for the given name.

fun spec(name: String): Descriptionfun spec(spec: Spec): Description

specUnsafe

fun specUnsafe(spec: Any): Description

test

fun test(name: String): Description