Dias
02/20/2020, 11:06 AMwasyl
02/20/2020, 11:07 AMforall
variant in suspend
package, so maybe you’re importing wrong version?io.kotlintest.data.suspend.forall
simon.vergauwen
02/20/2020, 11:07 AMDias
02/20/2020, 11:15 AMsimon.vergauwen
02/20/2020, 11:54 AMforAll(<http://Gen.int|Gen.int>(), Gen.string()) { int, string ->
...
}
forAll
Dias
02/20/2020, 12:53 PMsam
02/20/2020, 2:20 PMAJ Alt
02/22/2020, 12:05 AMsuspend
, that change means they can't be used in non-suspending contexts. Some large teams at Microsoft make extensive use of forall
with a JUnit test runner. 4.0.0-BETA1
is unusable for them.
I think we should either make forAll
non-suspending, but take a suspending lambda, or continue to provide both suspending and non-suspending versions of the functions.sam
02/22/2020, 12:16 AMsimon.vergauwen
02/22/2020, 11:40 AMYou can’t take a suspend lamba and run it in a non suspend function I don’t thinkYou can if you implement a basic runtime for
suspend
like Arrow Fx and KotlinX do. Or you need to wrap in IO
or Deferred
so you can delay executing the suspend
from a non-suspend function.forAll
becomes a DSL a nested DSL of TestCase
, that way your suspend
is wrapped in TestCase
and you can run them yourself later however you wantsam
02/23/2020, 10:04 PMsimon.vergauwen
02/24/2020, 8:38 AMsuspend
runner would solve your problem. Which is quite easy to do.Junit
understand with an adaption layer that has a suspend
runner, no?TestCase
into junitAJ Alt
02/24/2020, 5:21 PMrunBlocking
in the KotestEngine.
What if we changed to forall
to work like
fun forAll(vararg rows: Row, testfn: suspend (...) -> Unit) = runBlocking {...}
That would allow you to pass in suspend functions, but call forAll
from a blocking context. The behavior would stay the same as it is right now.simon.vergauwen
02/24/2020, 5:22 PMsam
02/24/2020, 5:37 PMsimon.vergauwen
02/24/2020, 5:39 PMI guess if we allocated each test a separate thread from Dispatchers.IO then it wouldn’t really matter.That sounds dangerous