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)
}waitForElementToExist()- waits untilelement.existsis truewaitForElementToNotExist()- waits untilelement.existsis falsewaitForActivityIndicatorToFinish()- 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.
- Install CocoaPods with
gem install cocoapods. pod init- In your Podfile, add
JAMTestHelperto your UI Testing target
target 'UI Tests' do
pod 'JAMTestHelper'
endClone 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.
This project was heavily inspired by my write-up on UI Testing and DHTestingAdditions.