September 2019
Intermediate to advanced
462 pages
11h 3m
English
“Prefer testing over debugging” is a good mantra to follow, but occasionally we have to debug code. Even when we follow good test-driven development practices, we’ll have to dig into the execution to look at why things aren’t working the way we expect. We’ll look at testing coroutines in Chapter 18, Unit Testing with Kotlin, but for now let’s figure out a way to find out which coroutines are running our code.
Kotlin provides a command-line option -Dkotlinx.coroutines.debug to display the details of the coroutine executing a function. When you print the details of a thread, the coroutine that’s running in that thread is displayed. Let’s use that option on the previous code.
| | $ kotlinc-jvm -Dkotlinx.coroutines.debug ... |
Read now
Unlock full access