You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
classDummyTestextendsAsyncWordSpecLikewithTableDrivenPropertyChecks {
"DummyExample" should {
valcases=Table(
("foo", "bar"),
(0, 1)
)
"be ok" in forAll(cases) { (foo, bar) =>valresult:Future[Assertion] =Future {
assert("a"=="a")
}
result
} // <- forAll returns Unit, which is not the `Future[Assertion]` that Async tests expect
}
}
The result expected by the async in {...} is Future[Assertion], but forAll returns Unit.
Is there a way to use both of them together?
The text was updated successfully, but these errors were encountered:
For reference, in case anyone is having the same issue and wants a workaround, you can use org.scalatest.wordspec.AnyWordSpecLike with org.scalatest.prop.TableDrivenPropertyChecks and org.scalatest.concurrent.ScalaFutures mix-ins and it will let you do .futureValue.
Just to oversimplify it:
valtable:TableFor1[BigDecimal] =???valfutureOperation:BigDecimal=>Future[BigDecimal] =???"my test" should {
"pass" in forAll(table) { foo =>
futureOperation(foo).futureValue shouldBe 300
}
}
Version of scalatest:
3.0.9
When you try to create tests like:
The result expected by the async
in {...}
isFuture[Assertion]
, butforAll
returnsUnit
.Is there a way to use both of them together?
The text was updated successfully, but these errors were encountered: