Right, the motivation there is that the method whi...
# strikt
c
Right, the motivation there is that the method which returns some value might itself be a suspending function. Having the
expect
lambda be suspending allows us to write tests like
Copy code
fun seedDatabase() {
    ...
}

suspend fun selectAllUsers() {
    ...
}

@BeforeEach
fun setup() {
    seedDatabase()
}

@Test
fun testQuery() {
    expect {
        that(selectAllUsers()).isNotEmpty()
    }
}
which is much more natural than
Copy code
fun seedDatabase() {
    ...
}

suspend fun selectAllUsers() {
    ...
}

@BeforeEach
fun setup() {
    seedDatabase()
}

@Test
fun testQuery() {
    expect {
        runBlocking {
            that(selectAllUsers()).isNotEmpty()
        }
    }
}