GreatExpectations 1.0.0

GreatExpectations 1.0.0

Maintained by Jack Rostron.



  • By
  • Jack Rostron

in2plane

<a href="https://swift.org/package-manager">
    <img src="https://img.shields.io/badge/spm-compatible-brightgreen.svg?style=flat" alt="Swift Package Manager" />
</a>

<a href="https://twitter.com/unsignedints">
    <img src="https://img.shields.io/badge/[email protected]?style=flat" alt="Twitter: @unsignedints" />
</a>

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
}