iOS单元测试通用应用程序 [英] iOS Unit testing universal application
问题描述
我正在尝试在通用应用程序上设置一些单元测试。在ipad / iphone上加载时,应用程序的行为完全不同。例如,每个单独的视图和控制器都有一个单独的委托。
I am trying to set up some unit tests on a universal application. The application behaves quite differently when loaded on ipad/iphone. For example there is a separate delegate for each, separate views and controllers as well.
如何配置要在iphone / ipad上测试的特定测试目标或特定测试文件。例如,在iPhone上运行TestsTarget1和在iPad上运行TestTarget2?可以在每个文件的基础上设置这样的东西吗?例如,TestIpadMaps.m将在iPad上运行,而TestIphoneMaps.m将在iphone上运行。
How can I configure a particular test target or particular test files to be tested on iphone/ipad. For example, run TestsTarget1 on iPhone and TestTarget2 on iPad? Can something like this be set on a per-file basis? For example "TestIpadMaps.m" to be run on iPad while "TestIphoneMaps.m" to be run on iphone.
编辑:我问的原因是因为我想对某些引用app委托的方法运行测试,这取决于正在测试的设备上。
The reason why I ask is because I want to run tests on certain methods that make reference to the app delegate which is different depending on the device it is being tested on.
推荐答案
您可以使用if语句检查NS(或者它可能是UI,因为我在iPad上,所以我没有参考)设备等于iPhone,如果它运行你的测试或GoTo你的视图。
You could use an if statement to check if NS (or it could be UI as I'm on my iPad so I don't have reference)device is equal to iPhone and if it is run your test or GoTo your view.
这是一个视频,将有助于
Here is a video that will help
http://www.youtube.com/watch?v = meiv1ePUEnM
这篇关于iOS单元测试通用应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!