Hello there. Is there any smart way to test (in ju...
# coroutines
j
Hello there. Is there any smart way to test (in junits) if there’s no blocking IO calls inside a suspending function? Let’s say I can
mockk
a potentially blocking dependency (in my case it would be
org.apache.kafka.clients.producer.KafkaProducer#send(...)
which returns some
Future<...>
)
d
j
❤️
Thank you!
oh, unfortunately BlockHoud does not raise alarm on
Future.get()
😞
d
Well,
Future.get
itself is not necessarily blocking. But if the
Future.get
call actually makes the thread sleep, I think BlockHound will react. At least I don't remember any explicit exceptions being made for
Future.get
, and I don't think they would make sense.
j
yeah, I think now it was my mistake on guessing how/when BlockHound would intervene and I simply didn’t give it a chance to raise anything 🙂 And while I solved my whole problem with rethinking approach, thank you for pointing me to this BlockHound project, for sure it will come handy another time 🙂