Is there any more convenient pattern for invoking ...
# kotest
e
Is there any more convenient pattern for invoking two blocking things that depend on each other than doing the following?
Copy code
test("client-server test") {
  listOf(
    async { client.sendRequest() }
    async { 
      val req = server.takeRequest()
      req.path shouldBe "/api/v1/hello"
    }
  ).joinAll()
}
r
I would personally do something like below.
coroutineScope
will wait for all child coroutines to complete before exiting;`async` is meant to be used with
.await()
, so if you don't care about the return value you can just use
launch
.
Copy code
test("client-server test") {
  coroutineScope {
    launch { client.sendRequest() }
    launch { 
      val req = server.takeRequest()
      req.path shouldBe "/api/v1/hello"
    }
  }
}
Coroutines aren't necessarily the best fit if both
sendRequest()
and
takeRequest()
are blocking, but it may not matter for a test.
e
will try that, thx 🙂