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

gab6jxml  于 2023-05-08  发布在  其他
关注(0)|答案(1)|浏览(170)

如何确保assert失败后异步测试不会继续?在做了一些研究之后,我明白我必须使用@MainActorasync来确保我的restAPI集按顺序运行。然而,在我的例子中,我不希望在Assert失败后继续测试。但是我怎么能做到呢?

@MainActor func testAsync() async throws {
        XCTAssert(false)
        print("xxxxxxx")
    }
jm81lzqq

jm81lzqq1#

与现有的其他单元测试框架不同,XCTest中Assert失败时的默认行为是继续测试。
但您可以使用以下命令更改此设置:

continueAfterFailure = false

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

相关问题