not sure where to post this, but when you use `run...
# announcements
d
not sure where to post this, but when you use
runBlocking {}
in junit tests and you have
assertEquals()
as the last call (or any kotlin test assertion) it doesn't work, because tests should have
Unit
return type, but since
asserEquals
returns stuff, junit doesn't pick up the test. What can I do? I can just put
Unit
in the end of the call, but it does't look good
t
Why are you asserting inside of the runBlocking?
d
I treat whole body test as a block
t
what are you running asynchronously?
d
stuff
t
launch { } doesn't return anything
I think that might help you
d
but I need it to finish before test executes
having
val x = runBlocking {}
within the test body doesn't look good either
t
I can't think of a way to get around the ugliness that runBlocking causes in such a test 😄
p
write
runBlocking<Unit> { }
? 🙂
👍 2
d
that works, thanks! I knew that would be easy solution
but the bit I am missing is: I tried doing thing like
Copy code
fun test(): Unit = runBlocking {}
but it complained about expected type mismatch
why doesn't it do it here?
k
I think the behavior you're looking for is called "forward inference", and Kotlin doesn't have it simple smile