teabot
teabot

Reputation: 15444

Unit testing an iPhone static library with XCode 3

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?

Upvotes: 4

Views: 2135

Answers (3)

Tarek Jradi
Tarek Jradi

Reputation: 101

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

Upvotes: 2

ronaldmathies
ronaldmathies

Reputation: 154

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

Upvotes: -1

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.

Upvotes: 7

Related Questions