首页 > 解决方案 > 如何强制按顺序运行 ZIO 测试

问题描述

我想按顺序运行两个集成测试。这如何在ZIO Test中实现?

这是套房:

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并行运行这两个测试。有没有办法强制它们按顺序运行?

标签: scalaintegration-testingziozio-test

解决方案


是的!您可以TestAspect.sequential为此使用:

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

推荐阅读