To use GHUnit in your project, you’ll need to create and configure a test target.
- Add a
New Target
. SelectCocoa -> Application
. Name itTests
(or something similar). - In the Finder, copy
GHUnit.framework
to your project directory (maybe in MyProject/Frameworks/.) - In the
Tests
target, add theGHUnit.framework
files (from MyProject/Frameworks/). It should now be visible as aLinked Framework
in the target. - In the
Tests
target, under Build Settings, add@loader_path/../Frameworks
toRunpath Search Paths
(Under All Configurations) - In the
Tests
target, addNew Build Phase
|New Copy Files Build Phase
.- Change the Destination to
Frameworks
. - Drag
GHUnit.framework
into the the build phase - Make sure the copy phase appears before any
Run Script
phases
- Change the Destination to
-
Copy
GHUnitTestMain.m
into your project and include in the Test target. -
If your main target is a library:
- In the
Target 'Tests' Info
window,General
tab:- Add a linked library, and select your main target; This is so you can link your test target against your main target, and then you don’t have to manually include source files in both targets.
- In the
-
If your main target is an application, you will need to include these source files to the
Test
project manually. -
Now create a test (either by subclassing
SenTestCase
orGHTestCase
), adding it to your test target. (See example test case below.) - By default, the Tests-Info.plist file includes
MainWindow
forMain nib file base name
. You should clear this field. - Now you can create and run tests!