Weird behavior of `should throw`
See original GitHub issueHi Markus!
I’m trying to do this:
@Test
fun `assert throws exceptions`() {
invoking { factory.create("") } `should throw` IllegalArgumentException::class
}
But have a compile error:
org/junit/ComparisonFailure
java.lang.NoClassDefFoundError: org/junit/ComparisonFailure
at org.amshove.kluent.ExceptionsKt.shouldThrow(Exceptions.kt:14)
at org.amshove.kluent.ExceptionsBacktickKt.should throw(ExceptionsBacktick.kt:5)
...
Do you have any clues?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
What causes this weird behavior with throwing destructors ...
1) an exception is thrown and not caught (it is implementation-defined whether any stack unwinding is done in this case).
Read more >Should a function throw exceptions based on its expected ...
One is to throw. Throwing an exception is slow (compared to alternatives). Stack traces don't concatenate themselves for free. Because of this ...
Read more >Weird behavior with re-thrown error in IntelliJ IDEA (JAVA)
This warning will be shown if the something() method is not annotated as throws Exception . In this case, your catch clause will...
Read more >[Solved]-C++ : Throw Exception weird behavior?
What happens when I throw a C++ exception from a native Java method? How to make a mock object throw an exception in...
Read more >Disruptive Behavior: Why It's Often Misdiagnosed
Many people assume that kids who act out or throw tantrums are angry ... In order to be diagnosed with ODD, the disruptive...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The dependency to JUnit is a known limitation at the moment, which I’ve got rid of (switched to
kotlin.test) for the multiplatform branch.The problem is, that using JUnit exceptions has better IDE integration (e.g. diff windows on comparison failures) which
kotlin.testdidn’t do (at least at the time).It might be worth to check out if this has been resolved in
kotlin.testyet 😃The diff window for IntelliJ seems to also support formatting of the exception message, maybe we can build up on that. The RegEx can be found here, although it has junit4 in the package name, so it needs to be tested if it works with something else than
ComparisonFailure