简体   繁体   English

Xcode 7中的特定UI测试

[英]Specific UI Testing in Xcode 7

I am new to UI Testing in Xcode 7, and I find it very difficult to determinate how can I test multiple details about my app. 我是Xcode 7中的UI测试的新手,我发现很难确定如何测试有关我的应用程序的多个详细信息。 I have been able to test the basic things, such as different labels exist, and their values are changed when I tap the corresponding buttons. 我已经能够测试一些基本的东西,例如存在不同的标签,并且当我点击相应的按钮时,它们的值也会更改。

However, I have no idea how can I test that the color of these labels changes to the one desired, or that a new screen is presented modally when I tap a button. 但是,我不知道如何测试这些标签的颜色是否变为所需的颜色,或者当我点击一个按钮时以模态方式显示一个新屏幕。 After searching in Google and Stackoverflow I have found nothing but the basic tutorials that let me test what I have already accomplished. 在Google和Stackoverflow中搜索之后,除了基本的教程可以让我测试已经完成的工作之外,我什么都没有找到。 How should I proceed to expand my tests and make them actually useful? 我应该如何继续扩展测试并使它们真正有用?

There are some limitations. 有一些限制。 I don't believe testing color (or fonts for example) is possible... yet. 我不认为可以测试颜色(例如字体)。 However you can definitely test the navigation from screen to screen... 但是,您绝对可以测试屏幕之间的导航...

XCTAssertTrue(app.navigationBars["ViewControllerTitle"].exists)

Of course, it all depends on how your screen works. 当然,这完全取决于屏幕的工作方式。 In the example, we're assuming there is a disabled navigation bar label. 在该示例中,我们假设有一个禁用的导航栏标签。 You just have to find something visual (text) on the screen that uniquely identifies it. 您只需要在屏幕上找到可以唯一标识它的视觉(文本)内容即可。 It does take some getting used to. 确实需要一些习惯。

As stated, the specifics for testing for color are not yet possible. 如前所述,尚无法测试颜色。 However, you might want to consider Unit Tests for that. 但是,您可能需要为此考虑单元测试。 You can test GUI components for color in those. 您可以在其中测试GUI组件的颜色。 That's where the line between Unit and UI Testing can get a bit blurry. 这就是单元测试和UI测试之间的界线可能变得有些模糊的地方。 But, if you need to test for color, that is one way to do it. 但是,如果您需要测试颜色,那是一种方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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