xctest中异步测试失败后停止测试

问题描述 投票:0回答:1

如何确保我的异步测试在断言失败后不会继续?在做了一些研究之后,我明白我必须使用

@MainActor
async
来确保我的 restAPI 集按顺序运行。但是,就我而言,我不希望断言失败后继续测试。但是我该怎么做呢?

    @MainActor func testAsync() async throws {
        XCTAssert(false)
        print("xxxxxxx")
    }
ios swift xcode async-await xctest
1个回答
0
投票

与现有的所有其他单元测试框架不同,XCTest 中失败断言的默认行为是继续测试。

但是您可以通过以下方式更改此设置:

continueAfterFailure = false

https://developer.apple.com/documentation/xctest/xctestcase/1496260-continueafterfailure

© www.soinside.com 2019 - 2024. All rights reserved.