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

jvmTest.com.bkahlert.kommons.test.KommonsTestTest.kt Maven / Gradle / Ivy

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

import com.bkahlert.kommons.test.com.bkahlert.kommons.StackTrace
import com.bkahlert.kommons.test.com.bkahlert.kommons.get
import io.kotest.matchers.paths.shouldBeADirectory
import io.kotest.matchers.paths.shouldBeAbsolute
import io.kotest.matchers.paths.shouldExist
import io.kotest.matchers.should
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import org.junit.jupiter.api.Test

class KommonsTestTest {

    @Test
    fun locations() = testAll(
        KommonsTest.Work,
        KommonsTest.Home,
        KommonsTest.Temp,
        KommonsTest.JavaHome,
    ) {
        it.shouldBeAbsolute()
        it.shouldExist()
        it.shouldBeADirectory()
    }

    @Test fun locate_call() = test {
        KommonsTest.locateCall() should {
            it.fileName shouldBe "KommonsTestTest.kt"
            it.className shouldBe KommonsTestTest::class.qualifiedName
            it.methodName shouldBe "locate_call"
            it.lineNumber shouldBe 28
        }

        KommonsTest.locateCall(StackTrace(StackTrace.get().dropWhile { !it.className.startsWith("org.junit") })) should {
            it.fileName shouldNotBe "KommonsTestTest.kt"
        }

        KommonsTest.locateCall(RuntimeException()) should {
            it.fileName shouldBe "KommonsTestTest.kt"
            it.className shouldBe KommonsTestTest::class.qualifiedName
            it.methodName shouldBe "locate_call"
            it.lineNumber shouldBe 39
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy