在 XCTest 中用于评估 Swift 并发异步表达式的断言函数。
XCTest
框架中缺失的并发函数
不用再写
import XCTest
func test_should_succeed() async {
do {
let isTrue = try await shouldSucceed()
XCTAssertTrue(isTrue)
} catch {
XCFail("Should not throw an error")
}
}
可以方便地写成
import SwiftAsyncAssert
func test_should_succeed() async {
await AsyncAssertTrue(try await shouldSucceed())
}
func test_should_throwError() async {
await AsyncAssertThrowsError(try await shouldFail())
}
更少的代码,方便您的测试!