bnorm / kotlin-power-assert

Kotlin compiler plugin to enable diagrammed function calls in the Kotlin programming language
Apache License 2.0
581 stars 15 forks source link

Diagram is shown twice when using kotlin.check #106

Closed rocketraman closed 6 months ago

rocketraman commented 6 months ago

When doing tests in commonTest we don't have access to kotlin.assert, which appears to only be available on JVM and native.

So, I tried to use check instead, which works, but shows the diagram twice:

  @Test
  fun foo() {
    check("foo" == "bar") { "Failed foo=bar" }
  }
Failed foo=bar
check("foo" == "bar") { "Failed foo=bar" }
            |
            false
java.lang.IllegalStateException: Failed foo=bar
check("foo" == "bar") { "Failed foo=bar" }
            |
            false

Also shows twice if the lazyMessage param is not given.

bnorm commented 6 months ago

I think this may be an IDE oddity, rather than something specific to kotlin-power-assert. I think your IDE (looks like an output from IntelliJ) is showing you the message of the exception the test is failing with and then dumping the stacktrace of the exception which also includes the error message. I suspect if you remove kotlin-power-assert from your build you will observe the same behavior, just without the diagram.

rocketraman commented 6 months ago

I think this may be an IDE oddity, rather than something specific to kotlin-power-assert.

Yep, you're right. Weird that I've never noticed that before. Sorry for the noise!

rocketraman commented 6 months ago

More context if anyone else comes upon this in the future: