Swiftpack.co - Package - unsignedintellects/GreatExpectations

in2plane
Swift Package Manager Twitter: @unsignedints

A wrapper around XCTestCase that makes working with XCTestExpectations much cleaner

Overview

Turn this:

let exp = expectation(description: #function)

AsyncTask {
	exp.fulfill()
}

waitForExpectations(timeout: 5)

Into this:

expect { expectation in
	AsyncTask {
		expectation.fulfill()
	}
}

It may not look like much of an improvement, but it allows async unit tests to be written without having to explicitly declare an instance of XCTestExpectation and then declaring for how long to wait for.

The method signature defaults the expectation name to be #function for clarity with a timeout of 5 seconds. Both of these can be overidden:

expect("Test Name", limitingTo: 3.0) { expectation in
	// Perform async task
}

Github

link
Stars: 0
Help us keep the lights on

Dependencies

Used By

Total: 0