I’m probably being thick, but I’m finding that I d...
# kotest
r
I’m probably being thick, but I’m finding that I don’t get nice coroutine stacktraces in IntelliJ when my test fails in an
eventually
block. VM options:
-ea -Dkotlinx.coroutines.debug=on -Dkotlinx.coroutines.stacktrace.recovery=true
(belt, braces, stapled on to stomach).
Yet the stack is still useless - only references the one line in my code where the assertion actually failed.
s
is the stack just full of kotlin references rather than your own code ?
r
Yup
I can stick it up here if you’re feeling masochistic.
s
sure
r
Copy code
Test failed after 1000ms; attempted 35 times; first cause was Collection should contain element Message(from=sniper@auctionhost.internal/Auction, text=expectedMessage); listing some elements [Message(from=sniper@auctionhost.internal/Auction, text=SOLVersion: 1.1; Command: JOIN;)]; last cause was Collection should contain element Message(from=sniper@auctionhost.internal/Auction, text=expectedMessage); listing some elements [Message(from=sniper@auctionhost.internal/Auction, text=SOLVersion: 1.1; Command: JOIN;)]
java.lang.AssertionError: Test failed after 1000ms; attempted 35 times; first cause was Collection should contain element Message(from=sniper@auctionhost.internal/Auction, text=expectedMessage); listing some elements [Message(from=sniper@auctionhost.internal/Auction, text=SOLVersion: 1.1; Command: JOIN;)]; last cause was Collection should contain element Message(from=sniper@auctionhost.internal/Auction, text=expectedMessage); listing some elements [Message(from=sniper@auctionhost.internal/Auction, text=SOLVersion: 1.1; Command: JOIN;)]
	(Coroutine boundary)
	at io.kotest.core.internal.TestCaseExecutor$executeAndWait$2$1$1$3.invokeSuspend(TestCaseExecutor.kt:201)
	at io.kotest.mpp.ReplayKt.replay(replay.kt:18)
	at io.kotest.core.internal.TestCaseExecutor$executeAndWait$2$1$1.invokeSuspend(TestCaseExecutor.kt:200)
	at io.kotest.core.internal.TestCaseExecutor$executeAndWait$2$1.invokeSuspend(TestCaseExecutor.kt:195)
	at io.kotest.core.internal.TestCaseExecutor.executeAndWait(TestCaseExecutor.kt:192)
	at io.kotest.core.internal.TestCaseExecutor.invokeTestCase(TestCaseExecutor.kt:161)
	at io.kotest.core.internal.TestCaseExecutor.executeActiveTest(TestCaseExecutor.kt:130)
	at io.kotest.core.internal.TestCaseExecutor$intercept$2.invokeSuspend(TestCaseExecutor.kt:80)
	at io.kotest.core.internal.TestCaseExecutor.executeIfActive(TestCaseExecutor.kt:94)
	at io.kotest.core.internal.TestCaseExecutor.intercept(TestCaseExecutor.kt:80)
	at io.kotest.core.internal.TestCaseExecutor.execute(TestCaseExecutor.kt:61)
	at io.kotest.engine.runners.SingleInstanceSpecRunner.runTest(SingleInstanceSpecRunner.kt:73)
Caused by: java.lang.AssertionError: Test failed after 1000ms; attempted 35 times; first cause was Collection should contain element Message(from=sniper@auctionhost.internal/Auction, text=expectedMessage); listing some elements [Message(from=sniper@auctionhost.internal/Auction, text=SOLVersion: 1.1; Command: JOIN;)]; last cause was Collection should contain element Message(from=sniper@auctionhost.internal/Auction, text=expectedMessage); listing some elements [Message(from=sniper@auctionhost.internal/Auction, text=SOLVersion: 1.1; Command: JOIN;)]
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTaskKt.resume(DispatchedTask.kt:176)
	at kotlinx.coroutines.DispatchedTaskKt.dispatch(DispatchedTask.kt:111)
	at kotlinx.coroutines.CancellableContinuationImpl.dispatchResume(CancellableContinuationImpl.kt:308)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeImpl(CancellableContinuationImpl.kt:318)
	at kotlinx.coroutines.CancellableContinuationImpl.resumeUndispatched(CancellableContinuationImpl.kt:400)
	at kotlinx.coroutines.EventLoopImplBase$DelayedResumeTask.run(EventLoop.common.kt:489)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at io.kotest.engine.ExecutorExecutionContext.executeWithTimeoutInterruption(ExecutorExecutionContext.kt:45)
	at io.kotest.core.internal.TestCaseExecutor$executeAndWait$2.invokeSuspend(TestCaseExecutor.kt:194)
	at io.kotest.core.internal.TestCaseExecutor$executeAndWait$2.invoke(TestCaseExecutor.kt)
	at kotlinx.coroutines.intrinsics.UndispatchedKt.startUndispatchedOrReturnIgnoreTimeout(Undispatched.kt:102)
	at kotlinx.coroutines.TimeoutKt.setupTimeout(Timeout.kt:120)
	at kotlinx.coroutines.TimeoutKt.withTimeout(Timeout.kt:37)
	at io.kotest.core.internal.TestCaseExecutor.executeAndWait(TestCaseExecutor.kt:192)
	at io.kotest.core.internal.TestCaseExecutor.invokeTestCase(TestCaseExecutor.kt:161)
	at io.kotest.core.internal.TestCaseExecutor.executeActiveTest(TestCaseExecutor.kt:130)
	at io.kotest.core.internal.TestCaseExecutor$intercept$2.invokeSuspend(TestCaseExecutor.kt:80)
	at io.kotest.core.internal.TestCaseExecutor$intercept$2.invoke(TestCaseExecutor.kt)
	at io.kotest.core.internal.TestCaseExecutor.executeIfActive(TestCaseExecutor.kt:94)
	at io.kotest.core.internal.TestCaseExecutor.intercept(TestCaseExecutor.kt:80)
	at io.kotest.core.internal.TestCaseExecutor.execute(TestCaseExecutor.kt:61)
	at io.kotest.engine.runners.SingleInstanceSpecRunner.runTest(SingleInstanceSpecRunner.kt:73)
	at io.kotest.engine.runners.SingleInstanceSpecRunner$execute$2$invokeSuspend$$inlined$invoke$lambda$1.invokeSuspend(SingleInstanceSpecRunner.kt:83)
	at io.kotest.engine.runners.SingleInstanceSpecRunner$execute$2$invokeSuspend$$inlined$invoke$lambda$1.invoke(SingleInstanceSpecRunner.kt)
	at io.kotest.engine.spec.SpecRunner$runParallel$$inlined$map$lambda$2$1.invokeSuspend(SpecRunner.kt:80)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
	at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:274)
	at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:84)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:59)
	at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
	at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking$default(Builders.kt:38)
	at kotlinx.coroutines.BuildersKt.runBlocking$default(Unknown Source)
	at io.kotest.engine.spec.SpecRunner$runParallel$$inlined$map$lambda$2.run(SpecRunner.kt:79)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
	at java.base/java.lang.Thread.run(Thread.java:832)
Caused by: java.lang.AssertionError: Collection should contain element Message(from=sniper@auctionhost.internal/Auction, text=expectedMessage); listing some elements [Message(from=sniper@auctionhost.internal/Auction, text=SOLVersion: 1.1; Command: JOIN;)]
	at goos.auction.stub.StubAuctionDriver$hasReceivedMessage$2.invokeSuspend(StubAuctionDriver.kt:49)
	at goos.auction.stub.StubAuctionDriver$hasReceivedMessage$2.invoke(StubAuctionDriver.kt)
	at io.kotest.assertions.timing.EventuallyKt.eventually-RI63U9M(Eventually.kt:39)
	at io.kotest.assertions.timing.EventuallyKt$eventually$4.invokeSuspend(Eventually.kt)
	... 45 more
(Points for anyone who recognises what I’m doing…)
s
ebay sniper?
so its because eventually is keeping the first and last errors, and just showing the messages
so it's just a limitation of the way we've coded it
can you make an issue on github, we can change that to print the entire stack
r
Sure, will do
(It’s the main exercise from Growing Object Oriented Software Guided by Tests)
s
ah nice
is it a kotest thing
or a generic test thing
r
The book? It’s from 2009.
s
oh lol
that's a few haircuts ago
r
Yup, having to transpose it into kotlin / mockk / gradle / kotest ensures that I’ve really understood what they are trying to teach.
s
nice, good idea
fun little project
then you can start doing tickets on kotest 😛
r
I probably owe you one or two!
s
well next time you're in chicago you can buy me one
or next time I'm in the uk
r
Sure. If we ever get to travel again.
s
ha, in 2032
😂 2
😢 1