All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jvmMain.com.bkahlert.kommons.test.junit.DisplayName.kt Maven / Gradle / Ivy

There is a newer version: 2.8.0
Show newest version
package com.bkahlert.kommons.test.junit

import org.junit.jupiter.api.extension.ExtensionContext

/** Display name of a test which is resolved in the scope a test execution. */
public class DisplayName(
    /** Display names of all ancestors. */
    public val ancestorDisplayNames: List,
    /** Display name. */
    public val displayName: String,
) : CharSequence by displayName {
    internal constructor(extensionContext: ExtensionContext) : this(
        extensionContext.ancestors.reversed().map { it.displayName },
        extensionContext.displayName,
    )

    /** Composed display name consisting of all display names but the root display name separated by ` ➜ `. */
    public val composedDisplayName: String
        get() = buildList {
            addAll(ancestorDisplayNames.drop(1))
            add(displayName)
        }.joinToString(" ➜ ")

    override fun toString(): String = displayName
}

public fun ExtensionContext.displayName(): DisplayName = DisplayName(this)




© 2015 - 2024 Weber Informatics LLC | Privacy Policy