I have a very simple XCTestCase implementation that checks for a button click and expects an Alert controller to appear. The problem is that the tap() method is not working. Placing a breakpoint in an associated IBAction button I understand that logic is not even called.
class uitestsampleUITests: XCTestCase { var app: XCUIApplication! override func setUp() { super.setUp() continueAfterFailure = false app = XCUIApplication() app.launch() } func testButton() { let button = app.buttons["Button"] button.tap() expectationForPredicate(NSPredicate(format: "exists == 1"), evaluatedWithObject: button, handler: nil) waitForExpectationsWithTimeout(5.0, handler: nil) } }
In addition, duplicating the button.tap() command makes a test pass as follows:
func testButton() { let button = app.buttons["Button"] button.tap() button.tap() expectationForPredicate(NSPredicate(format: "exists == 1"), evaluatedWithObject: button, handler: nil) waitForExpectationsWithTimeout(5.0, handler: nil) }
I ran into this problem in Xcode 7.3.1 Am I missing something? This is mistake?
ios integration-testing swift xcode-ui-testing
Xavi gil
source share