Skip to content

Commit

Permalink
Add Stacktrace property to dachlatten-debug
Browse files Browse the repository at this point in the history
  • Loading branch information
janseeger committed Sep 29, 2023
1 parent 8a421f3 commit d893c54
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package de.sipgate.dachlatten.debug

val stacktrace: String
get() = Thread.currentThread()
.stackTrace
.drop(2)
.joinToString(separator = "\n")
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package de.sipgate.dachlatten.debug

import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test

class StacktraceKtTest {

@Test
fun stacktraceReturnsStacktrace() {
val result = stacktrace

assertTrue(result.contains("stacktraceReturnsStacktrace"))
}

@Test
fun stacktraceReturnsInnerFuncStacktrace() {
fun innerFunc() = stacktrace

val result = innerFunc()

assertTrue(result.contains("\$innerFunc"))
}
}

0 comments on commit d893c54

Please sign in to comment.