4

I am writing a number of static libraries for the iPhone and wish also to have suites of unit tests. XCode 3 provides templates for both static libraries and unit tests but I am wondering how they should fit together in a static library project?

In my static library project I have created a target for unit testing but expect to also create an executable to kick off the unit tests than run against the classes in the static library.

What is the procedure for doing this?

teabot
  • 15,358
  • 11
  • 64
  • 79

3 Answers3

7

Note that some classes of tests (like anything that would rely on the system calls such as [UIApplication sharedApplication] working require a separate target, while pure logic tests do not.

Create a new project with Unit Test and see what is added - basically you can do the same thing easily, create a new target and select "Unit Test Bundle" as the target type.

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
  • Great - I can execute these now when building - but how can I debug said unit tests? – teabot Jul 07 '09 at 19:55
  • Please also anyone stuck on this check out some more details over on this thread: http://stackoverflow.com/a/11267670/662605 – Daniel Jun 29 '12 at 19:17
2

you have to add all your .m related files in the unit test target. (Just drag and drop!)

Tarek Jradi
  • 101
  • 7
-1

In case people still have problems with using static libraries:

I've created an article that explains how to create static libraries and how to use them within projects:

Xcode: The complete explanation on how to use static libraries: http://www.sodeso.nl/?p=822

And for the unit testing part of static libraries, i don't have an explanation on how to set it up but i do have created a static library template that uses Google Toolkit for Map unit testing framework which you can download and add to your Xcode installation:

Xcode: Static library template with Google Toolkit for Mac Testing framework: http://www.sodeso.nl/?p=982

ronaldmathies
  • 154
  • 2
  • 6