0

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?

Drux
  • 11,162
  • 10
  • 62
  • 111
  • This sounds more like something for UI Automation than XCTest. What are you testing with C in your example? – psobko Feb 12 '15 at 00:40
  • @psobko I want to automate (also) testing of UI code with XCTest. `C` performs a non-UI operation but for its operation on `A` and `B` to be in place. – Drux Feb 12 '15 at 05:28

1 Answers1

0

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

Ajith R Nayak
  • 4,676
  • 4
  • 33
  • 40
Drux
  • 11,162
  • 10
  • 62
  • 111