2

For my setUp and tearDown methods in an XCTest suite, I need to call [[UIApplication sharedApplication] delegate] and then have it perform a signout method. The signout appears to call the correct methods, but many properties on the sharedApplication are nil and it does not actually sign the application out. The application does sign out during a normal run. I presume this has to do with the way singletons affect unit tests. Does anyone know why this might be?

  • The same problem. As for me - the `[UIApplication sharedApplication]` is also nil. – skywinder Jul 10 '14 at 13:24
  • The same question without answer: http://stackoverflow.com/questions/21530605/getting-nil-value-for-the-variable-in-unit-test-using-xctest – skywinder Jul 10 '14 at 13:40

1 Answers1

0

Try to:

  1. Remove your existing Test Target

  2. Create new Test Target (5-th tab in left pane -> click on + in bottom left corner -> New Test Target) and

  3. In appeared window don't forget to choose your application as target of your test target.

  4. Add all your TestCases files to new target.

I don't know the reason, but after this action it start working correctly, when I run tests with new target.

skywinder
  • 21,291
  • 15
  • 93
  • 123