Currently I'm learning about androidx Room and I w...
# android
m
Currently I'm learning about androidx Room and I would like to test my DAO's. One of my DAOs looks like that:
Copy code
@Dao
interface ApplicationResourceDao{
    @Transaction
    @Query("SELECT * FROM application_resources")
    fun getAll(): Flow<List<ApplicationResourceEntity>>
}
on the test side, I'm doing like that:
Copy code
@Test
fun getApplications() = runTest {
    insertApplicationResources()

    val allApplications = applicationResourceDao.getAll().toList()

    assertEquals(2, allApplications.size)
}
but I'm getting infinite loop on the getAll due to the Flow. how can I test a flow on this case?
z
j
toList
collects all emissions and continues until the Flow completes, but a Flow from Room will never completed on its own. You probably meant to grab the first list of items from the database with
first
m
Thank you for the replies. I finally understand what I was doing wrong.
🙌 1