Mix AsyncWordSpec with PropertyChecks in ScalaTest

Viewed 202

I want to mix AsyncWordSpec with property driven tests in ScalaTest.

So far, I have the following:

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)
    }
...

I want to create a property based version of "insert an order" which replaces the hard-coded value of id with a forAll { id: Int => ... } construct.

Unfortunately, forAll doesn't return a Future[Assertion], so I haven't found a way to combine these 2 testing styles.

Is there a way to combine AsyncWordSpec and PropertyChecks?

0 Answers
Related