简体   繁体   中英

Fails a simple test case using KIF

I try to use KIF in swift project. I run test case on iPhone simulator. Probably I did not set up correctly KIF because use it first time. I used this manual

Test fails in this simple code

func testSelectingOrganizerRole() { tester().tapView(withAccessibilityLabel: "ORGANIZE") }

with reason: 在此处输入图片说明

A button with Accessibility label "ORGANIZE" exists on initial ViewConroller of storyboard.

Why don't you switch to the UI tests framework available since Xcode 7? A quick intro:

UI testing gives you the ability to find and interact with the UI of your app in order to validate the properties and state of the UI elements.

UI testing includes UI recording, which gives you the ability to generate code that exercises your app's UI the same way you do, and which you can expand upon to implement UI tests. This is a great way to quickly get started writing UI tests.

Using this framework, your simple test would look like this:

let app = XCUIApplication()
app.launch()
app["ORGANIZE"].tap()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM