Casey Brooks
09/25/2018, 5:06 PMexpect
lambda
be suspending allows us to write tests like
fun seedDatabase() {
...
}
suspend fun selectAllUsers() {
...
}
@BeforeEach
fun setup() {
seedDatabase()
}
@Test
fun testQuery() {
expect {
that(selectAllUsers()).isNotEmpty()
}
}
which is much more natural than
fun seedDatabase() {
...
}
suspend fun selectAllUsers() {
...
}
@BeforeEach
fun setup() {
seedDatabase()
}
@Test
fun testQuery() {
expect {
runBlocking {
that(selectAllUsers()).isNotEmpty()
}
}
}