Here is how you configure a new target to run tests with GHUnit:
Download the GHUnitIOS framework. Note the name, don't download the one for OS X.
Add a new target to your project.
Add the following frameworks:
GHUnitIOS.framework
,
CoreGraphics.framework
,
Foundation.framework
,
UIKit.framework
,
CoreLocation.framework
In Build Settings > Other Linker
Flags add -ObjC
and -all_load
Edit the ...-Info.plist
for your target with a text editor and comment the following:
<!--
<key>NSMainNibFile</key>
<string>MainWindow</string>
-->
- Add the
GHUnitIOSTestMain.m
file into your project.
- In the build settings of your new target, remove the file
main.m
.
- In the .pch file for your new target add
#import <GHUnitIOS/GHUnit.h>
Now add a test:
// this import is already in the pch
// #import <GHUnitIOS/GHUnit.h>
@interface MyTest : GHTestCase { }
@end
@implementation MyTest
- (void)testFoo {
// assert that foo is not nil
GHAssertNotNULL(foo, @"foo was nil");
}
@end
Your test methods should start with test
. There are other methods you can add like setUp
, tearDown
, setUpClass
, tearDownClass
, and a number of GHAssertxxx
assertions.