question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Weird behavior of `should throw`

See original GitHub issue

Hi 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:open
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
MarkusAmshovecommented, Nov 3, 2020

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.test didn’t do (at least at the time).

It might be worth to check out if this has been resolved in kotlin.test yet 😃

0reactions
MarkusAmshovecommented, Feb 22, 2021

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found