Swiftpack.co - mochidev/XCTAsync as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by mochidev.
mochidev/XCTAsync 1.0.1
Swift library to more easily test async code
⭐️ 33
🕓 1 year ago
.package(url: "https://github.com/mochidev/XCTAsync.git", from: "1.0.1")

XCTAsync

Test Status

XCTAsync redefines many XCTAssert functions as async functions within asynchronous contexts.

Installation

Add XCTAsync as a dependency in your Package.swift file to start using it. Then, add import XCTAssert to any file you wish to use the library in.

Please check the releases for recommended versions.

dependencies: [
    .package(url: "https://github.com/mochidev/XCTAsync.git", .upToNextMajor(from: "1.0.0")),
],
...
targets: [
    .testTarget(
        name: "MyPackageTests",
        dependencies: [
            "XCTAsync",
        ]
    )
]

What is XCTAsync?

XCTAsync is a collection of functions for testing asynchonous code:

import XCTest
import XCTAsync

func testAsyncMethods() async {
    await XCTAssertTrue(await asynchronousMethod())
}

Note that XCTAsync is only necessary for async methods, and will not be overloaded in synchronous contexts:

import XCTest
import XCTAsync

func testSyncMethods() {
    XCTAssertTrue(synchronousMethod())
}

However, if you are in an asynchronous test, you'll need to use the asynchronous variants for each assert:

import XCTest
import XCTAsync

func testSyncMethods() async {
    await XCTAssertTrue(synchronousMethod())
}

Contributing

Contribution is welcome! Please take a look at the issues already available, or start a new issue to discuss a new feature. Although guarantees can't be made regarding feature requests, PRs that fit with the goals of the project and that have been discussed before hand are more than welcome!

Please make sure that all submissions have clean commit histories, are well documented, and thoroughly tested. Please rebase your PR before submission rather than merge in main. Linear histories are required.

GitHub

link
Stars: 33
Last commit: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Related Packages

Release Notes

Version 1.0.1
1 year ago

What's Changed

Full Changelog: https://github.com/mochidev/XCTAsync/compare/1.0.0...1.0.1

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics