Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/94.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
测试iOS用户界面时,Xctasertrue不会失败_Ios_Objective C_Xcode Ui Testing - Fatal编程技术网

测试iOS用户界面时,Xctasertrue不会失败

测试iOS用户界面时,Xctasertrue不会失败,ios,objective-c,xcode-ui-testing,Ios,Objective C,Xcode Ui Testing,我正在测试一个别人写的计算器。我正在尝试使用xcode 7测试所有基本功能 这是我目前正在运行的不会失败的测试。我已经使用了新的录音功能,以获得所有的按钮点击。然而,我不确定如何断言我得到的值是正确的 - (void)testExample { // Use recording to get started writing UI tests. XCUIApplication *app = [[XCUIApplication alloc] init]; [app.buttons[@"6"] ta

我正在测试一个别人写的计算器。我正在尝试使用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);

}

xctasertrue不会测试一个值是否等于另一个值,如果这是您所期望的


xctaserttrue测试除0(nil)以外的任何值。您的
显示
不是零;因此,这是正确的,并且测试通过。

您基本上希望检查带有该标签的XUIElement是否存在。:

XCTAssertTrue(display.exists)

那么,我是否应该将显示转换为int,并将值与xctasertequals进行比较?我尝试过这样做,但我不知道如何将XUIElement转换为int。我还没有弄清楚您认为自己在做什么或想做什么,您也没有解释它。所以我已经解释了你的问题,也就是为什么你的考试总是通过。