简体   繁体   English

Xcode故事板模拟器测试

[英]Xcode Storyboard Simulator test

Is there a way to test views individually from storyboard in Xcode. 有没有一种方法可以从Xcode的情节提要中单独测试视图。 For example I want to test my last view that is part of navigation controller directly on simulator by passing the prior ones. 例如,我想通过传递先前的视图来直接在模拟器上测试属于导航控制器的最后一个视图。

I am using Xcode 7.2. 我正在使用Xcode 7.2。

You can use XcTest also check out this article on XcTest. 您还可以使用XcTest,也可以在XcTest上查看本文

If you are looking to do Behavioral Driven-Development, like navigating through a Navigation stack of segues, like a user would, you can programmatically add Touch events etc in your XCTests: 如果您希望进行行为驱动的开发,例如像浏览用户一样浏览导航,可以在XCTests中以编程方式添加Touch事件等:

how to programmatically fake a touch event to a UIButton? 如何以编程方式将触摸事件伪造到UIButton?

With XcTest you can see what UI elements are visible, what .text values they have, for example. 使用XcTest,您可以看到哪些UI元素可见,例如,它们具有哪些.text值。

If you trying to quickly get to a particular view, so you can see how it looks, without navigating to that view every time the only thing I can think of is to use "Is Initial View Controller" for the UIView and mock any data that might need to be passed to that View to display it properly: 如果您试图快速进入一个特定的视图,那么您可以看到它的外观,而不必每次都导航到该视图,我唯一想到的就是对UIView使用“是初始视图控制器”并模拟所有可能需要将其传递给该视图才能正确显示它:

在此处输入图片说明

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

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