asserts should support kotlin coroutines support.
See original GitHub issueI am trying to test network connectivity and by method is a suspend function. It work be nice if there is coroutine support present like mockito provides, for example, coAssertThat().
Currently, we need to wrap the assert call inside runBlocking{} scope.
runBlocking {             assertThat(mockNetworkInfo.isConnected())         }
it would be nice if this support is provided so that all we need to do is:
 coAssertThat(mockNetworkInfo.isConnected())
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
 Top Results From Across the Web
Top Results From Across the Web
Testing Kotlin coroutines on Android
Unit testing code that uses coroutines requires some extra attention, as their execution can be asynchronous and happen across multiple threads.
Read more >Testing Kotlin Coroutines - Kt. Academy
To use TestCoroutineScheduler on coroutines, we should use a dispatcher that supports it. The standard option is StandardTestDispatcher . Unlike most ...
Read more >kotlinx-coroutines-test
The coroutine dispatcher used for tests is single-threaded, meaning that the child coroutines of the runTest block will run on the thread that...
Read more >Assertions in kotlin coroutines / callback - Stack Overflow
Which call is suspending here? · Hmm believe it or not, that is actually a good question. · I added a stripped version...
Read more >Kotlin Flow Assert Delight - Coding with Mohit
Let's look at a simple example we could write a test for. The snippet below shows a repository that takes in an API...
Read more > Top Related Medium Post
Top Related Medium Post
No results found
 Top Related StackOverflow Question
Top Related StackOverflow Question
No results found
 Troubleshoot Live Code
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free Top Related Reddit Thread
Top Related Reddit Thread
No results found
 Top Related Hackernoon Post
Top Related Hackernoon Post
No results found
 Top Related Tweet
Top Related Tweet
No results found
 Top Related Dev.to Post
Top Related Dev.to Post
No results found
 Top Related Hashnode Post
Top Related Hashnode Post
No results found

I do not know of any. But I’ll start following that JUnit 5 issue (despite being extremely bearish on 5.x).
If you wanted to get really, really creative with JUnit 4 I believe you can do this as a custom test runner. You would discover the test methods yourself which would be in the form
and then invoke them with some very low-level coroutine machinery.
I could be convinced to be nerd-sniped by this task… I just have to find the time…
And, of course, the big problem here is that JUnit 4 test runners do not compose so you couldn’t combine it with parameterized or anything else.
Sounds good will try to implement this.