Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

A few additions to XCTest geared towards UI Testing in Xcode 7 and iOS 9.

License

Notifications You must be signed in to change notification settings

Ling/JAMTestHelper

Open more actions menu
 
 

Repository files navigation

JAMTestHelper

Requires Xcode 7 Beta 4

A few additions to XCTest geared towards UI Testing in Xcode 7 and iOS 9.

- (void)testLikeButton {
    let button = app.buttons["Like"]

    button.tap()
    waitForActivityIndicatorToFinish()

    let label = app.staticTexts["1 like"]
    waitForElementToExist(label)

    button.tap()
    waitForElementToNotExist(label)
}

Helpers

  • waitForElementToExist() - waits until element.exists is true
  • waitForElementToNotExist() - waits until element.exists is false
  • waitForActivityIndicatorToFinish() - waits until the (assumed) only activity indicator stops animating

Both of these helpers work by ticking the run loop a tenth of a second in between checks. If the element does not meet the condition after two seconds an exception is raised.

Exceptions are used over XCTFail() so the tests' tests, JAMTestHelperTests.swift can run valid assertions. See that file for more details.

Installation

Cocoapods (recommended)

  1. Install CocoaPods with gem install cocoapods.
  2. pod init
  3. In your Podfile, add JAMTestHelper to your UI Testing target
target 'UI Tests' do
  pod 'JAMTestHelper'
end

Manual

Clone this repo and drag and drop JAMTestHelper.swift into your UI Testing target. You can then reference the methods inside of an XCTestCase as shown in the example.

Notes

This project was heavily inspired by my write-up on UI Testing and DHTestingAdditions.

About

A few additions to XCTest geared towards UI Testing in Xcode 7 and iOS 9.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 73.5%
  • Ruby 16.5%
  • Objective-C 10.0%
Morty Proxy This is a proxified and sanitized view of the page, visit original site.