Latest 1.0
License MIT
Frameworks XCTest


As of Xcode 6, Apple has created a first-party solution to writing asynchronous tests. See Testing with Xcode


XCTestAsync is an extension to XCTest for asynchronous testing, and is based on SenTestingKitAsync.


There are currently two ways to add XCTestAsync to your project:

  • Install with CocoaPods (recommended)
  • Manually copying the source files


CocoaPods is a dependency manager for Objective-C. To include XCTestAsync into your project with CocoaPods, edit your project’s podfile as follows:

target :test, :exclusive => true do
    pod 'XCTestAsync', '~> 1.0'


If you are not using CocoaPods, you can copy over XCTestAsync.h and XCTestAsync.m into your test target. In addition, you will need to add -ObjC to your test target linker flags.


To use XCTestAsync in your tests, do the following:

  1. Import the header:

    #import <XCTestAsync/XCTestAsync.h>
  2. Add your test method that ends with the suffix Async:

    - (void)testMethodAsync
        // your async code here
  3. Tell XCTestAsync when the test succeeds:
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, 2 * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^{

Once your async tests start, XCTestAsync will wait until either a failure occurs (by calling assertions such as XCTFail(…) or XCTAssert(…)) or a success is signalled (by calling XCAsyncSuccess()). If neither of these happen, XCTestAsync will wait indefinitely.


If you expect your async test to run within a specified amount of time, you can specify a time limit by calling XCAsyncFailAfter(timeout, description, …). If a success is not signalled within the time limit, the test will fail after timeout number of seconds.

Additional Reading

Latest podspec

    "name": "XCTestAsync",
    "version": "1.0",
    "summary": "Extension to XCTest for asynchronous testing",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "James Hu": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0"
    "source_files": "XCTestAsync/XCTestAsync.{h,m}",
    "frameworks": "XCTest",
    "xcconfig": {
        "FRAMEWORK_SEARCH_PATHS": ""$(inherited)" "$(SDKROOT)/Developer/Library/Frameworks" "$(DEVELOPER_LIBRARY_DIR)/Frameworks""
    "requires_arc": true

Pin It on Pinterest

Share This