Can kotlin.test.assertEquals provide a link to diff like org.junit.assertEquals?

When running tests in IntelliJ, is there a way to get kotlin.junit.assertEquals to output a <Click to see difference> link in the console the same way org.junit.Assert.assertEquals does?

It is extremely convenient to see a difference in text, especially for long text without line breaks:

Vs. Kotlin assert console only output:

Or is the right solution to use Kotlin for tests but with JUnit for assertEquals?

You can add a dependency on kotlin-test-junit or kotlin-test-junit5 artifact in the jvm sourceSet of your project. Then assertEquals will be throwing org.junit.ComparisonFailure exception instead of java.lang.AssertionError on a failed assertEquals check, and IDEA will be able to extract from that the expected and actual values.

1 Like

Thank you Ilya.