在 ScalaTest 中将 AsyncWordSpec 与 PropertyChecks 混合使用

Fel*_*lix 5 asynchronous scala scalatest

我想将 AsyncWordSpec 与 ScalaTest 中的属性驱动测试混合使用。

到目前为止,我有以下几点:

class SQLPersistenceSpec extends AsyncWordSpec with Matchers with EitherValues with PropertyChecks{

...

  "SQLPersistence" should {

...

    "insert an order" in {
      val persistence = H2CodeRepository(h2URL)

      persistence
        .insertOrder(id, orderedBy, productId, freeOfCharge)
        .map(_.right.value shouldBe 1)
    }
...
Run Code Online (Sandbox Code Playgroud)

我想创建一个基于属性的“插入订单”版本,它id用一个forAll { id: Int => ... }构造替换 的硬编码值。

不幸的是,forAll不返回 a Future[Assertion],所以我还没有找到结合这两种测试风格的方法。

有没有办法结合AsyncWordSpecPropertyChecks