scalaintegration-testingziozio-test

How to enforce to run ZIO Tests sequentially


I want to run two integration tests sequentially. How can this be achieved in ZIO Test?

Here is the Suite:

suite("Undeploy a Package")(
    testM("There is a Package") {
      PackageDeployer.deploy(pckg) *> // first deploy
        assertM(PackageUndeployer.undeploy(pckg), equalTo(StatusCode.NoContent))
    },
    testM(s"There is no Package") {
        assertM(PackageUndeployer.undeploy(pckg), equalTo(StatusCode.NotFound))
    })

ZIO Test runs the two tests in parallel. Is there a way to enforce that they are run in Sequence?


Solution

  • Yes! You can use TestAspect.sequential for that:

    suite("Undeploy a Package")(
        testM("There is a Package") {
          PackageDeployer.deploy(pckg) *> // first deploy
            assertM(PackageUndeployer.undeploy(pckg), equalTo(StatusCode.NoContent))
        },
        testM(s"There is no Package") {
            assertM(PackageUndeployer.undeploy(pckg), equalTo(StatusCode.NotFound))
        }) @@ sequential