# JUnit Coroutines Runner

DevFeed: [JUnit Coroutines Runner](<https://devfeed.tech/articles/junit-coroutines-runner-38650.md>)

Original publisher: [Read original article](<https://krossovochkin.com/posts/2021_07_10_junit_coroutines_runner/>)

Published: 2021-07-10T00:00:00Z

Content type: tutorial

Language: en

Sources: [Vasya Drobushkov](<https://devfeed.tech/sources/vasya-drobushkov.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Coroutines](<https://devfeed.tech/topics/coroutines.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [coroutines](<https://devfeed.tech/tags/coroutines.md>), [junit](<https://devfeed.tech/tags/junit.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [kotlin-compiler](<https://devfeed.tech/tags/kotlin-compiler.md>), [runner](<https://devfeed.tech/tags/runner.md>), [suspend-function](<https://devfeed.tech/tags/suspend-function.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

This tutorial explores how to reduce repeated runBlockingTest setup in Kotlin coroutine tests by creating a custom JUnit rule. It explains the resulting suspend-function and bytecode validation issues and investigates their root cause.

## Source excerpt

Introduction Recently while writing tests for kotlin code with coroutines I found one annoying thing: almost all the tests start with runBlockingTest. Typing the same stuff repeatedly is something we can't accept! So, I decided to think about how to improve this. Disclaimer. Yes, this is an example of how to spend few hours to optimize some task that requires you 2 seconds to complete each time. Even on a scale of hundreds of usages such optimization most likely won't pay your time back. But it is always fun to do some weird things even if you understand that they are stupid.