Skip to content

angu-software/SwiftAsyncAssert

Repository files navigation

SwiftAsyncAssert

version build status

Assert functions to evaluate Swift concurrency async expressions in XCTests.

The Missing concurrency functions in XCTest framework


Instead of writing

import XCTest

func test_should_succeed() async {
    do {
        let isTrue = try await shouldSucceed()
        XCTAssertTrue(isTrue)
    } catch {
        XCFail("Should not throw an error")
    }
}

conveniently write

import SwiftAsyncAssert

func test_should_succeed() async {
    await AsyncAssertTrue(try await shouldSucceed())
}

func test_should_throwError() async {
    await AsyncAssertThrowsError(try await shouldFail())
}

Less code for your convenience when testing!