title: Coroutine testing fails with "This job has not completed yet"
body: <p>I'm following Craig Russell's blog post about testing coroutines: <a href="https://craigrussell.io/2019/11/unit-testing-coroutine-suspend-functions-using-testcoroutinedispatcher/" rel="noreferrer">https://craigrussell.io/2019/11/unit-testing-coroutine-suspend-functions-using-testcoroutinedispatcher/</a> but I can't get this test to pass:</p>
  <pre><code>@Test
  fun multipleLaunch() = runBlockingTest {
      var result = 0
      val jobs = mutableListOf&lt;Job&gt;()
      for (j in 0 until 10) {
          val job = launch(testDispatcherProvider.io()) {
              delay(1000)
              result++
          }
          jobs.add(job)
      }
      jobs.forEach { job -&gt;
          job.join()
      }
      assertEquals(10, result)
  }
  </code></pre>
  <p>Basically I'm launching a bunch of parallel jobs and want to get the result once all of them are finished.
  I'm getting this, by now classical exception:</p>
  <blockquote>
  <p>java.lang.IllegalStateException: This job has not completed yet</p>
  </blockquote>
  <p>Please advise how to get this to work as intended.</p>
  <p>My complete code:</p>
  <pre><code>class LaunchTest {
      @get:Rule
      var coroutinesTestRule = CoroutineTestRule()
  
      val testDispatcherProvider = object : DispatcherProvider {
          override fun io(): CoroutineDispatcher = coroutinesTestRule.testDispatcher
      }
  
      @Test
      fun multipleLaunch() = runBlockingTest {
          var result = 0
          val jobs = mutableListOf&lt;Job&gt;()
          for (j in 0 until 10) {
              val job = launch(testDispatcherProvider.io()) {
                  delay(1000)
                  result++
              }
              jobs.add(job)
          }
          jobs.forEach { job -&gt;
              job.join()
          }
          assertEquals(10, result)
      }
  }
  
  class CoroutineTestRule constructor(val testDispatcher: TestCoroutineDispatcher = TestCoroutineDispatcher()) : TestWatcher() {
      override fun starting(description: Description?) {
          super.starting(description)
          Dispatchers.setMain(testDispatcher)
      }
  
      override fun finished(description: Description?) {
          super.finished(description)
          Dispatchers.resetMain()
          testDispatcher.cleanupTestCoroutines()
      }
  }
  </code></pre>