title: When using kotlin coroutines, how do I unit test a function that calls a suspend function?
body: <p>I have a class like this</p>
  
  <pre><code>class SomeClass {
      fun someFun() {
          // ... Some synchronous code
          async {
              suspendfun() 
          }
      }
  
      private suspend fun suspendFun() {
           dependency.otherFun().await()
           // ... other code
      }
  }
  </code></pre>
  
  <p>I want to unit test <code>someFun()</code> so I wrote a unit test that looks like this:</p>
  
  <pre><code>@Test
  fun testSomeFun() {
      runBlocking {
          someClass.someFun()
      }
  
      // ... verifies &amp; asserts
  }
  </code></pre>
  
  <p>But this doesn't seem to work because runBlocking doesn't actually block execution until everything inside runBlocking is done. If I test <code>suspendFun()</code> directly inside <code>runBlocking</code> it works as expected but I want to be able to test <code>someFun()</code> all together. </p>
  
  <p>Any clue how to test a function with both sync and async code?</p>