2011-08-22 57 views

回答

2

你也可以看看已经通过良好的人在广场上发表了一个开放源代码的集成测试框架。看起来它可以帮助你自动执行某些如果你似乎是有意在UI级的交互测试。

我没有用这个框架自己,但已经意味着检查出来。

http://corner.squareup.com/2011/07/ios-integration-testing.html

希望这会有所帮助。

2

伪代码,我觉得你的测试会是这样的:

// in setUp, grab a reference to your desired view controllers & buttons 
// in the test method: 
// press a tab (or whatever it takes) to navigate to the Results view 
// press the button for the first result (using target/action or however you have it set up) 
    STAssertTrue([myNavigationController.visibleViewController isKindOfClass:[DetailViewController class]]); 
    STAssertTrue([(DetailViewController *)myNavigationController.visibleViewController result] == /*first result from earlier*/); 
// in tearDown, do cleanup if necessary 

如果这还不够,你应该张贴一些代码,所以我们可以帮助更容易。编号:setUp的更多相关信息。我认为这是值得看的,从示例代码链接到您的实现:

- (void) setUp { 
    app_delegate   = [[UIApplication sharedApplication] delegate]; 
    calc_view_controller = app_delegate.calcViewController; 
    calc_view   = calc_view_controller.view; 
} 

app_delegate,和calc_viewCalcApplicationTests类的实例变量,这样他们就可以从任何-test...方法中使用。作为应用程序控制器的本质,应用程序委托具有对主视图控制器的引用。我认为这是一个非常简单和理智的方式。

+0

我没有任何代码后, - 但是这是非常有帮助,谢谢! – Simon

+0

您可以添加一些关于如何获取控制器引用的详细信息吗? – Simon

+0

我没有一吨的这方面的经验要么,但我会在大约一个多一点的信息进行编辑。 – jtbandes

相关问题