when i use junits assertEquals and it fails i get ...
# intellij
c
when i use junits assertEquals and it fails i get a diff view in idea:
Copy code
org.opentest4j.AssertionFailedError: 
Expected :could not start restaurant after trying 3 times. ports tried: [55621, 55621, 55621]
Actual   :could not start restaurant after trying 3 times. ports tried: [55621,55621,55621]
<Click to see difference>
when I use assertEquals from kotlin.test this does not work:
Copy code
java.lang.AssertionError: Expected <could not start restaurant after trying 3 times. ports tried: [55859, 55859, 55859]>, actual <could not start restaurant after trying 3 times. ports tried: [55859,55859,55859]>.
l
What does the test code look like?
k
Which actual library is implementing
kotlin.test
? If it's kotlin.test.junit5, I would have expected the results to be identical. Also, if you're using the code from your recent thread, I'm surprised the actual result is without spaces:
arrayListOf(55859,55859,55859).toString() == "[55621, 55621, 55621]"
.
c
Right that was the error in my assertion but it was harder to find without a diff
a
that's strange,
org.opentest4j.AssertionFailedError
should be supported. Could you please share your test dependencies?
c
the first is supported, the second is not.
also i thought that gradle should automatically add the optional kotlin.test.junit5 dependency, will investigate
but anyway it would be great if kotlin.test would throw an exception that idea supports.
a
Ah, sorry. Actually the format could be supported by our regexp. Now it's not indeed. Should I submit a YT for you?
c
that would be perfect!
k
@Anna Kozlova I thought Christoph was talking about
kotlin.test
, not Kotest.
👍 1
1
If you don't specify that it should use the JUnit5 Asserter, then it will use its own default Asserter. So I think it's this default Asserter that gives an assertion error message that doesn't match IntelliJ's regexp. As a temporary or permanent workaround, you can use the JUnit5 Asserter, which will then give the exact same error message as JUnit5 and will therefore match the regexp and produce the "differences" behaviour you want.
c
yes i just added the
Copy code
kotlin("test-junit5")
and now it works. which is strange because at some point i had a problem that gradle added that dependency automatically when adding
kotlin("test")
(and i did not want that). now that I do it does not do it.