我正在测试别人编写的计算器。我正在尝试使用 xcode 7 来测试所有基本功能。
这是我目前正在运行的不会失败的测试。我使用了新的录音功能来获得所有的按钮点击。但是,我不确定如何断言我得到的值是正确的。
- (void)testExample {
// Use recording to get started writing UI tests.
XCUIApplication *app = [[XCUIApplication alloc] init];
[app.buttons[@"6"] tap];
[app.buttons[@"+"] tap];
[app.buttons[@"3"] tap];
[app.buttons[@"="] tap];
//what the equation should return (9 in this case)
XCUIElement *display = app.staticTexts[@"199"];
XCTAssertTrue(display);
//what the equation should look like (6 + 3 in this case)
display = app.staticTexts[@"222+5553"];
XCTAssertTrue(display);
}
最佳答案
您主要想检查带有该标签的 XCUIElement exists
:
XCTAssertTrue(display.exists)
关于ios - XCTAssertTrue 在测试 iOS UI 时不会失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32800700/