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

这是套房:

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并行运行两个测试。有没有一种方法可以强制它们按顺序运行?

最佳答案

是的!您可以为此使用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

关于scala - 如何强制依次运行ZIO测试,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/59643305/

10-09 13:46