title: Runblocking test never stops - Kotlin
body: <p>Im trying to cover with the test the function that get data from the firebase. I am wrapping the process within coroutine flow. According to debugger it jumps INSIDE  ONDATACHANGE. And it returns true on check if snapshot has child but debug misses when we call <code>snapshot.child(&quot;name&quot;).value.toString()</code></p>
  <pre><code>override suspend fun getData(id: String) = withContext&lt;User?&gt;(coroutineContext) {
      suspendCoroutine { cont -&gt;
          launch {
              val dbRef = firebaseDb.reference.child(&quot;users&quot;).child(id)
              dbRef.addListenerForSingleValueEvent(object : ValueEventListener {
                  override fun onDataChange(snapshot: DataSnapshot) {
                      if (snapshot.hasChild(&quot;name&quot;) &amp;&amp;
                          snapshot.hasChild(&quot;email&quot;)
                      ) {
                          val resultOne = snapshot.child(&quot;name&quot;).value.toString() //it stops here
                          val resultTwo = snapshot.child(&quot;email&quot;).value.toString()
  
                          saveAppsListInSharedPref(&quot;name&quot;, resultOne)
                          saveAppsListInSharedPref(&quot;email&quot;, resultTwo)
  
                          cont.resume(User(resultOne, resultTwo))
                      }
                  }
  
                  override fun onCancelled(error: DatabaseError) {
                      //error
                  }
              })
          }
      }
  }
  </code></pre>
  <p>And I got a test</p>
  <pre><code> @Test
      fun `getUser success`() : Unit = runBlocking {
          val userName = &quot;testUser&quot;
  
          whenever(firebaseDbMock.reference).thenReturn(databaseRef)
          whenever(databaseRef.child(anyString())).thenReturn(databaseRef)
  
          doAnswer { invocation -&gt;
              val valueEventListener = invocation.arguments[0] as ValueEventListener
              val mockedDataSnapshot: DataSnapshot = mock()
              whenever(mockedDataSnapshot.hasChild(&quot;name&quot;)).thenReturn(true)
              whenever(mockedDataSnapshot.hasChild(&quot;email&quot;)).thenReturn(true)
              whenever(&quot;name).value).thenReturn(&quot;testName&quot;)
              whenever(&quot;email&quot;).value.toString()).thenReturn(&quot;testEmail&quot;)
              valueEventListener.onDataChange(mockedDataSnapshot)
              null
          }.whenever(databaseRef).addListenerForSingleValueEvent(any())
  
              userDataRepository.getIconsList(userName)
      }
  }
  </code></pre>
  <p>On top of the class I got</p>
  <pre><code>@ExperimentalCoroutinesApi
  class MyClassTest {
      @get:Rule
      val mockWebServer = MockWebServer()
  
      @get:Rule
      val instantTaskExecutorRule = InstantTaskExecutorRule()
  
      private val firebaseDbMock: FirebaseDatabase = mock()
      private val sharedPreferencesMock: SharedPreferences = mock()
  </code></pre>
  <p>Not sure why it runs without stop can you give suggestions? Maybe the issue is because I am using launch{</p>