Skip to content

Instantly share code, notes, and snippets.

@joemasilotti
Created January 5, 2016 14:15
Embed
What would you like to do?
Stubbing out repeating animations in UI Testing
import XCTest
class TestCase: XCTestCase {
let app = XCUIApplication()
override func setUp() {
super.setUp()
continueAfterFailure = false
app.launchArguments = ["UI-Testing"]
app.launch()
}
func testExample() {
// your tests here
}
}
import UIKit
class Controller: UIViewController {
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
let options: UIViewAnimationOptions = UITesting() ? .TransitionNone : .Repeat
UIView.animateWithDuration(2, delay: 0, options: options, animations: { () -> Void in
// your animations here
}, completion: nil)
}
private func UITesting() -> Bool {
return NSProcessInfo.processInfo().arguments.contains("UI-TESTING")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment