iosmultithreadingsentestingkit

Launch test cases by hand (SenTestCase)? Need to wait for some background tasks before testing


I make some data loading from disk in the background.

My test should run after the runtime store has populated, but now tests runs paralel to my loading, which causes empty objects of course, so failed tests.

Any way to run the tests after my data loaded?


Solution

  • First of all, try to minimise your unit tests towards synchronous tasks. Logic tests should be designed in a way that minimises the dependency on other components.

    That said, you can build asynchronous tests if you insist to do so, and sometimes there are valid reasons (just not very often). Have a look at SenAsyncTestCase - it provides a number of base classes for such tests.