6

I would like to create a library for iOS applications which uses UIKit. Furthermore I would like to create unit tests for this library. Unfortunately my tests do not work because of UIKit ([UIFont systemFontOfSize:12.0] to be precise).

According to Apple's Unit Testing Guide there are two types of test cases: logic tests and application tests. Application tests seem to be the correct type for tests involving UIKit related stuff but I did not find out about how to set up application tests for libraries. Has anybody ever had the same problem and was able to solve it?

Thanks a lot!

zlajo
  • 2,173
  • 1
  • 19
  • 25

1 Answers1

5

I found a solution to this. You must add a new target to your project that is simply an empty application. Then use that application as your test host following the instructions for doing this with a regular application like here:

Why does instantiating a UIFont in an iphone unit test cause a crash?

Community
  • 1
  • 1
jasongregori
  • 11,451
  • 5
  • 43
  • 41