jvmTest.com.bkahlert.kommons.test.KommonsTestTest.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kommons-test Show documentation
Show all versions of kommons-test Show documentation
Kommons Test is a Kotlin Multiplatform Library to ease testing.
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
}
}
}