Unit testing asychronous UI code which does not know about XCTestExpectations?

谁说我不能喝 提交于 2019-12-12 01:55:26

问题


How can one go about unit-testing pieces of iOS code that work in a non-trivial graphical setup?

Consider for instance view controllers A and B, where A stacks B on top with performSegueWithIdentifier:sender:. A unit test should check the behavior of a C that depends on the two view controllers being arranged like that.

performSegueWithIdentifier:sender: works asynchronously, i.e. the unit test would end before it has completed its task unless one lets the unit test wait for something like an XCTestExpectation. But in a case like this neither B nor C is prepared to call fulfill on that expectation.

Is there a way forward in situations like this, i.e. for testing asynchronous UI code without ready hooks for calling fulfill?


回答1:


I have concluded that employing an integration test framework (such as KIF) is probably the way to go.



来源:https://stackoverflow.com/questions/28419994/unit-testing-asychronous-ui-code-which-does-not-know-about-xctestexpectations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!