问题
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