Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Updating examples

  • Loading branch information...
commit 609c9548e6dfbf72dd4d2a5c752de93afe1c86f4 1 parent 1397201
@gabriel gabriel authored
Showing with 1,075 additions and 289 deletions.
  1. +1 −0  CHANGELOG.md
  2. +0 −1  Classes-MacOSX/GHUnitTestMain.m
  3. +5 −0 Classes/GHTest/NSException+GHTestFailureExceptions.h
  4. +22 −0 Classes/GHTest/NSException+GHTestFailureExceptions.m
  5. +6 −1 Classes/GHTestMacros.h
  6. +2 −0  Classes/GHUnit.h
  7. +0 −1  Examples/MyTestable-IPhone/Libraries/GHUnit.framework/GHUnit
  8. BIN  Examples/MyTestable-IPhone/Libraries/GHUnit.framework/Versions/A/GHUnit
  9. +1 −0  Examples/MyTestable-IPhone/Libraries/GHUnitIOS.framework/GHUnitIOS
  10. 0  Examples/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Headers
  11. 0  Examples/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Resources
  12. BIN  Examples/MyTestable-IPhone/Libraries/GHUnitIOS.framework/Versions/A/GHUnitIOS
  13. 0  ...estable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHAsyncTestCase.h
  14. +1 −1  ...estable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTest+JUnitXML.h
  15. +1 −1  Examples/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTest.h
  16. 0  ...s/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTestCase.h
  17. +1 −1  ...le-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTestGroup+JUnitXML.h
  18. +22 −1 .../MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTestGroup.h
  19. +6 −1 ...MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTestMacros.h
  20. +1 −1  ...estable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTestOperation.h
  21. 0  ...MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTestRunner.h
  22. +1 −1  .../MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTestSuite.h
  23. +1 −1  ...es/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHTesting.h
  24. +83 −17 Examples/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHUnit.h
  25. 0  ...IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHUnitIPhoneAppDelegate.h
  26. 0  ...ibraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHUnitIPhoneTableViewDataSource.h
  27. 0  ...Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHUnitIPhoneTestViewController.h
  28. 0  ...stable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHUnitIPhoneView.h
  29. 0  ...one/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/GHUnitIPhoneViewController.h
  30. +5 −0 ...ries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/NSException+GHTestFailureExceptions.h
  31. +1 −1  ...Phone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Headers/NSValue+GHValueFormatter.h
  32. 0  ...s/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/A/Resources/Info.plist
  33. 0  Examples/MyTestable-IPhone/Libraries/{GHUnit.framework → GHUnitIOS.framework}/Versions/Current
  34. +4 −4 Examples/MyTestable-IPhone/MyTestable.xcodeproj/project.pbxproj
  35. +1 −1  Examples/MyTestable-IPhone/Tests/GHUnitIOSTestMain.m
  36. +1 −1  Examples/MyTestable-IPhone/Tests/MyTest.m
  37. BIN  Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/GHUnit
  38. +15 −6 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHAsyncTestCase.h
  39. +4 −0 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHMockNSHTTPURLResponse.h
  40. +11 −0 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHMockNSURLConnection.h
  41. +5 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHNSLocale+Mock.h
  42. +5 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTest+JUnitXML.h
  43. +4 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTest.h
  44. +7 −2 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestCase.h
  45. +5 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestGroup+JUnitXML.h
  46. +25 −0 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestGroup.h
  47. +226 −227 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestMacros.h
  48. +5 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestOperation.h
  49. +3 −0  Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestRunner.h
  50. +4 −0 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestSuite.h
  51. +5 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestViewModel.h
  52. +4 −0 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTesting.h
  53. +5 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHUNSObject+Swizzle.h
  54. +540 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHUnit.h
  55. +11 −2 ...ples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/NSException+GHTestFailureExceptions.h
  56. +5 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/NSValue+GHValueFormatter.h
  57. BIN  Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestView.nib
  58. BIN  Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestWindow.nib
  59. +1 −1  Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Resources/Info.plist
  60. +4 −2 Project-IPhone/GHUnitIPhone.xcodeproj/project.pbxproj
  61. +0 −2  Project/GHUnit.xcodeproj/project.pbxproj
  62. +1 −1  Project/Makefile
  63. +1 −1  Tests/GHKVObserveTest.m
  64. +4 −0 Tests/GHTestMacrosTest.m
  65. +1 −1  Tests/GHUnitIOSTestMain.m
  66. +8 −0 XcodeConfig/Shared-iPhone.xcconfig
View
1  CHANGELOG.md
@@ -4,6 +4,7 @@
- Fix issue #38
- Fix issue #39
- Fix issue #36
+- Fix issue #19
# Release 0.4.27
- Added in GHUnitIPhoneAppDelegate for subclassing test app delegate
View
1  Classes-MacOSX/GHUnitTestMain.m
@@ -59,7 +59,6 @@ int main(int argc, char *argv[]) {
For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
*/
-
NSSetUncaughtExceptionHandler(&exceptionHandler);
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
View
5 Classes/GHTest/NSException+GHTestFailureExceptions.h
@@ -70,6 +70,11 @@ extern NSString *const GHTestFailureException;
inFile:(NSString *)filename
atLine:(int)lineNumber
withDescription:(NSString *)formatString, ...;
++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left
+ andObject:(id)right
+ inFile:(NSString *)filename
+ atLine:(int)lineNumber
+ withDescription:(NSString *)formatString, ...;
+ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
andValue:(NSValue *)right
withAccuracy:(NSValue *)accuracy
View
22 Classes/GHTest/NSException+GHTestFailureExceptions.m
@@ -143,6 +143,28 @@ + (NSException *)ghu_failureInEqualityBetweenObject:(id)left
return [self ghu_failureInFile:filename atLine:lineNumber reason:reason];
}
++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left
+ andObject:(id)right
+ inFile:(NSString *)filename
+ atLine:(int)lineNumber
+ withDescription:(NSString *)formatString, ... {
+
+ NSString *testDescription = @"";
+ if (formatString) {
+ va_list vl;
+ va_start(vl, formatString);
+ testDescription =
+ [[[NSString alloc] initWithFormat:formatString arguments:vl] autorelease];
+ va_end(vl);
+ }
+
+ NSString *reason =
+ [NSString stringWithFormat:@"'%@' should not be equal to '%@'. %@",
+ [left description], [right description], testDescription];
+
+ return [self ghu_failureInFile:filename atLine:lineNumber reason:reason];
+}
+
+ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
andValue:(NSValue *)right
withAccuracy:(NSValue *)accuracy
View
7 Classes/GHTestMacros.h
@@ -429,7 +429,7 @@ if (([a1value isKindOfClass:[NSString class]] && \
(a1value == nil && [a2value isKindOfClass:[NSString class]]) || \
(a2value == nil && [a1value isKindOfClass:[NSString class]]) \
) continue; \
-[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
+[self failWithException:[NSException ghu_failureInInequalityBetweenObject: a1value \
andObject: a2value \
inFile: [NSString stringWithUTF8String:__FILE__] \
atLine: __LINE__ \
@@ -985,6 +985,11 @@ continue; \
inFile:(NSString *)filename
atLine:(int)lineNumber
withDescription:(NSString *)formatString, ...;
++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left
+ andObject:(id)right
+ inFile:(NSString *)filename
+ atLine:(int)lineNumber
+ withDescription:(NSString *)formatString, ...;
+ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
andValue:(NSValue *)right
withAccuracy:(NSValue *)accuracy
View
2  Classes/GHUnit.h
@@ -180,6 +180,7 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
For example <tt>ExampleTest.m</tt>:
@code
+ // For iOS
#import <GHUnitIOS/GHUnit.h>
// For Mac OS X
//#import <GHUnit/GHUnit.h>
@@ -232,6 +233,7 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
@section ExampleAsyncTestCase Example Async Test Case
@code
+ // For iOS
#import <GHUnitIOS/GHUnit.h>
// For Mac OS X
//#import <GHUnit/GHUnit.h>
View
1  Examples/MyTestable-IPhone/Libraries/GHUnit.framework/GHUnit
View
BIN  Examples/MyTestable-IPhone/Libraries/GHUnit.framework/Versions/A/GHUnit
Binary file not shown
View
1  Examples/MyTestable-IPhone/Libraries/GHUnitIOS.framework/GHUnitIOS
View
0  ...IPhone/Libraries/GHUnit.framework/Headers → ...one/Libraries/GHUnitIOS.framework/Headers
File renamed without changes
View
0  ...hone/Libraries/GHUnit.framework/Resources → ...e/Libraries/GHUnitIOS.framework/Resources
File renamed without changes
View
BIN  Examples/MyTestable-IPhone/Libraries/GHUnitIOS.framework/Versions/A/GHUnitIOS
Binary file not shown
View
0  ...work/Versions/A/Headers/GHAsyncTestCase.h → ...work/Versions/A/Headers/GHAsyncTestCase.h
File renamed without changes
View
2  ...work/Versions/A/Headers/GHTest+JUnitXML.h → ...work/Versions/A/Headers/GHTest+JUnitXML.h
@@ -41,4 +41,4 @@
@end
-//! @endcond
+//! @endcond
View
2  ...nit.framework/Versions/A/Headers/GHTest.h → ...IOS.framework/Versions/A/Headers/GHTest.h
@@ -181,4 +181,4 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
@end
-//! @endcond
+//! @endcond
View
0  ...framework/Versions/A/Headers/GHTestCase.h → ...framework/Versions/A/Headers/GHTestCase.h
File renamed without changes
View
2  ...Versions/A/Headers/GHTestGroup+JUnitXML.h → ...Versions/A/Headers/GHTestGroup+JUnitXML.h
@@ -39,4 +39,4 @@
@end
-//! @endcond
+//! @endcond
View
23 ...ramework/Versions/A/Headers/GHTestGroup.h → ...ramework/Versions/A/Headers/GHTestGroup.h
@@ -128,15 +128,36 @@
*/
- (void)addTestCase:(id)testCase;
+/*!
+ Add a test group to this test group.
+ @param testGroup Test group to add
+ */
- (void)addTestGroup:(GHTestGroup *)testGroup;
+/*!
+ Add tests to this group.
+ @param tests Tests to add
+ */
- (void)addTests:(NSArray */*of id<GHTest>*/)tests;
+/*!
+ Add test to this group.
+ @param test Test to add
+ */
- (void)addTest:(id<GHTest>)test;
+/*!
+ Whether the test group should run on the main thread.
+ Call passes to test case instance if enabled.
+ */
- (BOOL)shouldRunOnMainThread;
/*!
+ @result YES if we have any enabled chilren, NO if all children have been disabled.
+ */
+- (BOOL)hasEnabledChildren;
+
+/*!
Get list of failed tests.
@result Failed tests
*/
@@ -152,4 +173,4 @@
@end
-//! @endcond
+//! @endcond
View
7 ...amework/Versions/A/Headers/GHTestMacros.h → ...amework/Versions/A/Headers/GHTestMacros.h
@@ -429,7 +429,7 @@ if (([a1value isKindOfClass:[NSString class]] && \
(a1value == nil && [a2value isKindOfClass:[NSString class]]) || \
(a2value == nil && [a1value isKindOfClass:[NSString class]]) \
) continue; \
-[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
+[self failWithException:[NSException ghu_failureInInequalityBetweenObject: a1value \
andObject: a2value \
inFile: [NSString stringWithUTF8String:__FILE__] \
atLine: __LINE__ \
@@ -985,6 +985,11 @@ continue; \
inFile:(NSString *)filename
atLine:(int)lineNumber
withDescription:(NSString *)formatString, ...;
++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left
+ andObject:(id)right
+ inFile:(NSString *)filename
+ atLine:(int)lineNumber
+ withDescription:(NSString *)formatString, ...;
+ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
andValue:(NSValue *)right
withAccuracy:(NSValue *)accuracy
View
2  ...work/Versions/A/Headers/GHTestOperation.h → ...work/Versions/A/Headers/GHTestOperation.h
@@ -43,4 +43,4 @@
@end
-//! @endcond
+//! @endcond
View
0  ...amework/Versions/A/Headers/GHTestRunner.h → ...amework/Versions/A/Headers/GHTestRunner.h
File renamed without changes
View
2  ...ramework/Versions/A/Headers/GHTestSuite.h → ...ramework/Versions/A/Headers/GHTestSuite.h
@@ -115,4 +115,4 @@ extern NSString *GHUnitTest;
@end
-//! @endcond
+//! @endcond
View
2  ....framework/Versions/A/Headers/GHTesting.h → ....framework/Versions/A/Headers/GHTesting.h
@@ -145,4 +145,4 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
- (void)raiseAfterFailure;
@end
-//! @endcond
+//! @endcond
View
100 ...nit.framework/Versions/A/Headers/GHUnit.h → ...IOS.framework/Versions/A/Headers/GHUnit.h
@@ -76,12 +76,18 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
This manual is divided in the following sections:
- @subpage Examples
- @subpage Installing
+ - @subpage Building
- @subpage TestMacros
- @subpage EnvVariables
- @subpage CommandLine "Command Line & Makefiles"
- @subpage Customizing
- @subpage Hudson
+
+ @image html http://rel.me.s3.amazonaws.com/gh-unit/images/GHUnit-IPhone-0.4.18.png
+
+ @image html http://rel.me.s3.amazonaws.com/gh-unit/images/GHUnit-0.4.18.png
+
@section Notes Notes
GHUnit was inspired by and uses parts of GTM (google-toolbox-for-mac) code, mostly from UnitTesting: http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/UnitTesting/
@@ -97,9 +103,9 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
@section InstallingIOS Installing (iOS)
- Add a <tt>New Target</tt>. Select <tt>Cocoa Touch -> Application</tt>. Name it <tt>Tests</tt> (or something similar).
- - Add the <tt>GHUnit.framework</tt> to your project.
+ - Add the <tt>GHUnitIOS.framework</tt> to your project.
- Add the following frameworks to <tt>Linked Libraries</tt>:
- - <tt>GHUnit.framework</tt>
+ - <tt>GHUnitIOS.framework</tt>
- <tt>CoreGraphics.framework</tt>
- <tt>Foundation.framework</tt>
- <tt>UIKit.framework</tt>
@@ -107,7 +113,7 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
- Under 'Other Linker Flags' in the <tt>Tests</tt> target, add <tt>-ObjC</tt> and <tt>-all_load</tt>
- By default, the Tests-Info.plist file includes <tt>MainWindow</tt> for <tt>Main nib file base name</tt>. You should clear this field.
- Add the GHUnitIOSTestMain.m (http://github.com/gabriel/gh-unit/blob/master/Project-IPhone/GHUnitIOSTestMain.m) file into your project.
- - (Optional) Create and and set a prefix header (<tt>Tests_Prefix.pch</tt>) and add <tt>#import <GHUnit/GHUnit.h></tt> to it, and then you won't have to include that import for every test.
+ - (Optional) Create and and set a prefix header (<tt>Tests_Prefix.pch</tt>) and add <tt>#import <GHUnitIOS/GHUnit.h></tt> to it, and then you won't have to include that import for every test.
- (Optional) @ref Makefile "Install Makefile"
- @ref Examples "Create a test"
@@ -156,22 +162,37 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
*/
/*!
+ @page Building Building
+
+ For iOS, run <tt>make</tt> from within the <tt>Project-IPhone</tt> directory. The framework is in <tt>Project-IPhone/build/Framework/</tt>.
+
+ For Mac OS X, the framework build is stored in <tt>Project/build/Release/</tt>.
+ */
+
+/*!
@page Examples Examples
- @section ExampleIOS Example Test Class
+ - @ref ExampleTestCase
+ - @ref ExampleAsyncTestCase
+
+ @section ExampleTestCase Example Test Case
- For example <tt>MyTest.m</tt>:
+ For example <tt>ExampleTest.m</tt>:
@code
- #import <GHUnit/GHUnit.h>
+ // For iOS
+ #import <GHUnitIOS/GHUnit.h>
+ // For Mac OS X
+ //#import <GHUnit/GHUnit.h>
- @interface MyTest : GHTestCase { }
+ @interface ExampleTest : GHTestCase { }
@end
- @implementation MyTest
+ @implementation ExampleTest
- (BOOL)shouldRunOnMainThread {
// By default NO, but if you have a UI test or test dependent on running on the main thread return YES
+ return NO;
}
- (void)setUpClass {
@@ -190,12 +211,16 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
// Run after each test method
}
- - (void)testFoo {
+ - (void)testFoo {
+ NSString *a = @"foo";
+ GHTestLog(@"I can log to the GHUnit test console: %@", a);
+
// Assert a is not NULL, with no custom error description
GHAssertNotNULL(a, nil);
// Assert equal objects, add custom error description
- GHAssertEqualObjects(a, b, @"Foo should be equal to: %@. Something bad happened", bar);
+ NSString *b = @"bar";
+ GHAssertEqualObjects(a, b, @"A custom error message. a should be equal to: %@.", b);
}
- (void)testBar {
@@ -205,18 +230,59 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
@end
@endcode
- Now you should be ready to Build and Run the <tt>Test</tt> target.
+ @section ExampleAsyncTestCase Example Async Test Case
- For iOS, you should see something like:
+ @code
+ // For iOS
+ #import <GHUnitIOS/GHUnit.h>
+ // For Mac OS X
+ //#import <GHUnit/GHUnit.h>
- @image html http://rel.me.s3.amazonaws.com/gh-unit/images/GHUnit-IPhone-0.4.18.png
+ @interface ExampleAsyncTest : GHAsyncTestCase { }
+ @end
- An example of an iPhone project with GHUnit test setup can be found at: MyTestable-IPhone (http://github.com/gabriel/gh-unit/tree/master/Examples/MyTestable-IPhone).
+ @implementation ExampleAsyncTest
- For Mac OS X, you should see something like:
+ - (void)testURLConnection {
+
+ // Call prepare to setup the asynchronous action.
+ // This helps in cases where the action is synchronous and the
+ // action occurs before the wait is actually called.
+ [self prepare];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
+ NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
+
+ // Wait until notify called for timeout (seconds); If notify is not called with kGHUnitWaitStatusSuccess then
+ // we will throw an error.
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:10.0];
+
+ [connection release];
+ }
+
+ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
+ // Notify of success, specifying the method where wait is called.
+ // This prevents stray notifies from affecting other tests.
+ [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testURLConnection)];
+ }
- @image html http://rel.me.s3.amazonaws.com/gh-unit/images/GHUnit-0.4.18.png
+ - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
+ // Notify of connection failure
+ [self notify:kGHUnitWaitStatusFailure forSelector:@selector(testURLConnection)];
+ }
+ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
+ GHTestLog(@"%@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
+ }
+
+ @end
+ @endcode
+
+
+ @section ExampleProjects Example Projects
+
+ Example projects can be found at: http://github.com/gabriel/gh-unit/tree/master/Examples/
+
*/
/*!
@@ -507,7 +573,7 @@ fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@
the following in <tt>Test report XMLs</tt>:
@verbatim
- build/test-results/&#42;.xml
+ build/test-results/\*.xml
@endverbatim
That's all it takes. Check in a change that breaks one of your tests. Hudson
View
0  ...sions/A/Headers/GHUnitIPhoneAppDelegate.h → ...sions/A/Headers/GHUnitIPhoneAppDelegate.h
File renamed without changes
View
0  ...Headers/GHUnitIPhoneTableViewDataSource.h → ...Headers/GHUnitIPhoneTableViewDataSource.h
File renamed without changes
View
0  .../Headers/GHUnitIPhoneTestViewController.h → .../Headers/GHUnitIPhoneTestViewController.h
File renamed without changes
View
0  ...ork/Versions/A/Headers/GHUnitIPhoneView.h → ...ork/Versions/A/Headers/GHUnitIPhoneView.h
File renamed without changes
View
0  ...ns/A/Headers/GHUnitIPhoneViewController.h → ...ns/A/Headers/GHUnitIPhoneViewController.h
File renamed without changes
View
5 ...ers/NSException+GHTestFailureExceptions.h → ...ers/NSException+GHTestFailureExceptions.h
@@ -70,6 +70,11 @@ extern NSString *const GHTestFailureException;
inFile:(NSString *)filename
atLine:(int)lineNumber
withDescription:(NSString *)formatString, ...;
++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left
+ andObject:(id)right
+ inFile:(NSString *)filename
+ atLine:(int)lineNumber
+ withDescription:(NSString *)formatString, ...;
+ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
andValue:(NSValue *)right
withAccuracy:(NSValue *)accuracy
View
2  ...ions/A/Headers/NSValue+GHValueFormatter.h → ...ions/A/Headers/NSValue+GHValueFormatter.h
@@ -68,4 +68,4 @@
@end
// SENTE_END
-//! @endcond
+//! @endcond
View
0  ...framework/Versions/A/Resources/Info.plist → ...framework/Versions/A/Resources/Info.plist
File renamed without changes
View
0  ...braries/GHUnit.framework/Versions/Current → ...ries/GHUnitIOS.framework/Versions/Current
File renamed without changes
View
8 Examples/MyTestable-IPhone/MyTestable.xcodeproj/project.pbxproj
@@ -11,9 +11,9 @@
002D9D4E0F4918F1007932FE /* MyTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 002D9D4D0F4918F1007932FE /* MyTest.m */; };
002D9E0E0F491B49007932FE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
002D9E100F491B4C007932FE /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; };
- 0080406F1290AB9A0033DA60 /* GHUnit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0080406E1290AB9A0033DA60 /* GHUnit.framework */; };
0080407E1290AC280033DA60 /* GHUnitIOSTestMain.m in Sources */ = {isa = PBXBuildFile; fileRef = 0080407D1290AC280033DA60 /* GHUnitIOSTestMain.m */; };
00DA16640F899AF4001FE08E /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765FC0DF74451002DB57D /* CoreGraphics.framework */; };
+ 00EB37BF12F3A295000366F4 /* GHUnitIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 00EB37BE12F3A295000366F4 /* GHUnitIOS.framework */; };
1D3623260D0F684500981E51 /* MyTestableAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* MyTestableAppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
@@ -27,10 +27,10 @@
002D9D050F49177B007932FE /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = "<group>"; };
002D9D4D0F4918F1007932FE /* MyTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyTest.m; sourceTree = "<group>"; };
006A590E0FC4A7B600C79A81 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = System/Library/Frameworks/CoreLocation.framework; sourceTree = SDKROOT; };
- 0080406E1290AB9A0033DA60 /* GHUnit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GHUnit.framework; sourceTree = "<group>"; };
0080407D1290AC280033DA60 /* GHUnitIOSTestMain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GHUnitIOSTestMain.m; sourceTree = "<group>"; };
008040951290AC9E0033DA60 /* RunTests.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = RunTests.sh; sourceTree = "<group>"; };
00CDDE300F7703B40089C60E /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
+ 00EB37BE12F3A295000366F4 /* GHUnitIOS.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = GHUnitIOS.framework; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* MyTestableAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyTestableAppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* MyTestableAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyTestableAppDelegate.m; sourceTree = "<group>"; };
@@ -51,7 +51,7 @@
002D9E0E0F491B49007932FE /* Foundation.framework in Frameworks */,
002D9E100F491B4C007932FE /* UIKit.framework in Frameworks */,
00DA16640F899AF4001FE08E /* CoreGraphics.framework in Frameworks */,
- 0080406F1290AB9A0033DA60 /* GHUnit.framework in Frameworks */,
+ 00EB37BF12F3A295000366F4 /* GHUnitIOS.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -80,7 +80,7 @@
00DA15A30F897CDD001FE08E /* Libraries */ = {
isa = PBXGroup;
children = (
- 0080406E1290AB9A0033DA60 /* GHUnit.framework */,
+ 00EB37BE12F3A295000366F4 /* GHUnitIOS.framework */,
);
path = Libraries;
sourceTree = "<group>";
View
2  Examples/MyTestable-IPhone/Tests/GHUnitIOSTestMain.m
@@ -30,7 +30,7 @@
#import <UIKit/UIKit.h>
// If you are using the framework
-#import <GHUnit/GHUnit.h>
+#import <GHUnitIOS/GHUnit.h>
// If you are using the static library and importing header files manually
//#import "GHUnit.h"
View
2  Examples/MyTestable-IPhone/Tests/MyTest.m
@@ -6,7 +6,7 @@
// Copyright 2009. All rights reserved.
//
-#import <GHUnit/GHUnit.h>
+#import <GHUnitIOS/GHUnit.h>
@interface MyTest : GHTestCase { }
@end
View
BIN  Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/GHUnit
Binary file not shown
View
21 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHAsyncTestCase.h
@@ -31,10 +31,10 @@
// Some default statuses to use; Or define and use your own
enum {
- kGHUnitWaitStatusUnknown = 0,
- kGHUnitWaitStatusSuccess,
- kGHUnitWaitStatusFailure,
- kGHUnitWaitStatusCancelled
+ kGHUnitWaitStatusUnknown = 0, //!< Unknown wait status
+ kGHUnitWaitStatusSuccess, //!< Wait status success
+ kGHUnitWaitStatusFailure, //!< Wait status failure
+ kGHUnitWaitStatusCancelled //!< Wait status cancelled
};
/*!
@@ -46,6 +46,12 @@ enum {
Be sure to call prepare before the asynchronous method (otherwise an exception will raise).
@code
+
+ @interface MyAsyncTest : GHAsyncTestCase { }
+ @end
+
+ @implementation MyAsyncTest
+
- (void)testSuccess {
[self prepare];
@@ -61,6 +67,8 @@ enum {
// To ignore the check, forSelector can be NULL.
[self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testSuccess)];
}
+
+ @end
@endcode
*/
@interface GHAsyncTestCase : GHTestCase {
@@ -88,7 +96,6 @@ enum {
/*!
Prepare and specify the selector we will use in notify.
-
@param selector
*/
- (void)prepare:(SEL)selector;
@@ -112,7 +119,9 @@ enum {
*/
- (void)waitForStatus:(NSInteger)status timeout:(NSTimeInterval)timeout;
-// Deprecated
+/*!
+ @deprecated
+ */
- (void)waitFor:(NSInteger)status timeout:(NSTimeInterval)timeout;
/*!
View
4 ...yTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHMockNSHTTPURLResponse.h
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import <Foundation/Foundation.h>
/*!
@@ -44,3 +46,5 @@
- (void)setHeaders:(NSDictionary *)headers;
@end
+
+//! @endcond
View
11 .../MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHMockNSURLConnection.h
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import <Foundation/Foundation.h>
extern NSString *const GHMockNSURLConnectionException;
@@ -115,6 +117,13 @@ extern NSString *const GHMockNSURLConnectionException;
*/
- (void)receiveData:(NSData *)data afterDelay:(NSTimeInterval)delay;
+/*!
+ Send data to connection delegate.
+ @param data Data to send
+ @param statusCode HTTP status code
+ @param MIMEType Mime type
+ @param afterDelay Delay
+ */
- (void)receiveData:(NSData *)data statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)delay;
/*!
@@ -160,3 +169,5 @@ extern NSString *const GHMockNSURLConnectionException;
- (void)failWithError:(NSError *)error afterDelay:(NSTimeInterval)delay;
@end
+
+//! @endcond
View
6 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHNSLocale+Mock.h
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
/*!
Category for overriding the current locale at runtime.
@@ -38,7 +40,7 @@
[[NSLocale currentLocale] localeIdentifier] == "en_GB"
@endcode
*/
-@interface NSLocale (GHMock)
+@interface NSLocale(GHMock)
+ (void)gh_setLocaleIdentifier:(NSString *)localeIdentifier;
@@ -57,3 +59,5 @@
+ (NSArray *)gh_preferredLanguages;
@end
+
+//! @endcond
View
6 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTest+JUnitXML.h
@@ -27,9 +27,11 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import "GHTest.h"
-@interface GHTest (JUnitXML)
+@interface GHTest(JUnitXML)
/*!
Return test results in JUnit XML format for external parsing use
@@ -38,3 +40,5 @@
- (NSString *)JUnitXML;
@end
+
+//! @endcond
View
5 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTest.h
@@ -1,6 +1,6 @@
//
// GHTest.h
-// GHKit
+// GHUnit
//
// Created by Gabriel Handford on 1/18/09.
// Copyright 2009. All rights reserved.
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
/*!
Test status.
*/
@@ -179,3 +181,4 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
@end
+//! @endcond
View
9 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestCase.h
@@ -49,8 +49,13 @@
#import "GHTestMacros.h"
#import "GHTest.h"
-// Log to your test case logger.
-// For example, GHTestLog(@"Some debug info, %@", obj)
+/*!
+ Log to your test case logger.
+ For example,
+ @code
+ GHTestLog(@"Some debug info, %@", obj);
+ @endcode
+ */
#define GHTestLog(...) [self log:[NSString stringWithFormat:__VA_ARGS__, nil]]
/*!
View
6 ...s/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestGroup+JUnitXML.h
@@ -27,12 +27,16 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import "GHTestGroup.h"
-@interface GHTestGroup (JUnitXML)
+@interface GHTestGroup(JUnitXML)
- (NSString *)JUnitXML;
- (BOOL)writeJUnitXMLAtPath:(NSString *)documentsPath error:(NSError **)error;
@end
+
+//! @endcond
View
25 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestGroup.h
@@ -26,6 +26,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import "GHTest.h"
#import "GHTestCase.h"
@@ -126,15 +128,36 @@
*/
- (void)addTestCase:(id)testCase;
+/*!
+ Add a test group to this test group.
+ @param testGroup Test group to add
+ */
- (void)addTestGroup:(GHTestGroup *)testGroup;
+/*!
+ Add tests to this group.
+ @param tests Tests to add
+ */
- (void)addTests:(NSArray */*of id<GHTest>*/)tests;
+/*!
+ Add test to this group.
+ @param test Test to add
+ */
- (void)addTest:(id<GHTest>)test;
+/*!
+ Whether the test group should run on the main thread.
+ Call passes to test case instance if enabled.
+ */
- (BOOL)shouldRunOnMainThread;
/*!
+ @result YES if we have any enabled chilren, NO if all children have been disabled.
+ */
+- (BOOL)hasEnabledChildren;
+
+/*!
Get list of failed tests.
@result Failed tests
*/
@@ -149,3 +172,5 @@
- (void)runInOperationQueue:(NSOperationQueue *)operationQueue options:(GHTestOptions)options;
@end
+
+//! @endcond
View
453 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestMacros.h
@@ -77,6 +77,11 @@
// the License.
//
+/*!
+ @file GHTestMacros.h
+ @brief Assert macros for testing.
+ */
+
#import "NSException+GHTestFailureExceptions.h"
#import "NSValue+GHValueFormatter.h"
@@ -89,14 +94,16 @@ extern NSString *const GHTestFailureException;
#if defined(__cplusplus)
extern "C"
#endif
+
NSString *GHComposeString(NSString *, ...);
-// Generates a failure when a1 != noErr
-// Args:
-// a1: should be either an OSErr or an OSStatus
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+
+/*!
+ Generates a failure when a1 != noErr
+ @param a1 Should be either an OSErr or an OSStatus
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ...: A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertNoErr(a1, description, ...) \
do { \
@try {\
@@ -120,13 +127,13 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when a1 != a2
-// Args:
-// a1: received value. Should be either an OSErr or an OSStatus
-// a2: expected value. Should be either an OSErr or an OSStatus
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 != a2
+ @param a1 Rreceived value. Should be either an OSErr or an OSStatus
+ @param a2 Expected value. Should be either an OSErr or an OSStatus
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertErr(a1, a2, description, ...) \
do { \
@try {\
@@ -152,12 +159,12 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
} while(0)
-// Generates a failure when a1 is NULL
-// Args:
-// a1: should be a pointer (use GHAssertNotNil for an object)
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is NULL
+ @param a1 Should be a pointer (use GHAssertNotNil for an object)
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertNotNULL(a1, description, ...) \
do { \
@try {\
@@ -181,12 +188,12 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when a1 is not NULL
-// Args:
-// a1: should be a pointer (use GHAssertNil for an object)
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is not NULL
+ @param a1 should be a pointer (use GHAssertNil for an object)
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertNULL(a1, description, ...) \
do { \
@try {\
@@ -210,14 +217,13 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when a1 is equal to a2. This test is for C scalars,
-// structs and unions.
-// Args:
-// a1: argument 1
-// a2: argument 2
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is equal to a2. This test is for C scalars, structs and unions.
+ @param a1 Argument 1
+ @param a2 Argument 2
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertNotEquals(a1, a2, description, ...) \
do { \
@try {\
@@ -250,13 +256,13 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when a1 is equal to a2. This test is for objects.
-// Args:
-// a1: argument 1. object.
-// a2: argument 2. object.
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is equal to a2. This test is for objects.
+ @param a1 Argument 1. object.
+ @param a2 Argument 2. object.
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertNotEqualObjects(a1, a2, desc, ...) \
do { \
@try {\
@@ -282,14 +288,14 @@ withDescription:GHComposeString(desc, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when a1 is not 'op' to a2. This test is for C scalars.
-// Args:
-// a1: argument 1
-// a2: argument 2
-// op: operation
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is not 'op' to a2. This test is for C scalars.
+ @param a1 Argument 1
+ @param a2 Argument 2
+ @param op Operation
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertOperation(a1, a2, op, description, ...) \
do { \
@try {\
@@ -323,61 +329,60 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when a1 is not > a2. This test is for C scalars.
-// Args:
-// a1: argument 1
-// a2: argument 2
-// op: operation
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is not > a2. This test is for C scalars.
+ @param a1 argument 1
+ @param a2 argument 2
+ @param op operation
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertGreaterThan(a1, a2, description, ...) \
GHAssertOperation(a1, a2, >, description, ##__VA_ARGS__)
-// Generates a failure when a1 is not >= a2. This test is for C scalars.
-// Args:
-// a1: argument 1
-// a2: argument 2
-// op: operation
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is not >= a2. This test is for C scalars.
+ @param a1 argument 1
+ @param a2 argument 2
+ @param op operation
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertGreaterThanOrEqual(a1, a2, description, ...) \
GHAssertOperation(a1, a2, >=, description, ##__VA_ARGS__)
-// Generates a failure when a1 is not < a2. This test is for C scalars.
-// Args:
-// a1: argument 1
-// a2: argument 2
-// op: operation
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when a1 is not < a2. This test is for C scalars.
+ @param a1 argument 1
+ @param a2 argument 2
+ @param op operation
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertLessThan(a1, a2, description, ...) \
GHAssertOperation(a1, a2, <, description, ##__VA_ARGS__)
-// Generates a failure when a1 is not <= a2. This test is for C scalars.
-// Args:
-// a1: argument 1
-// a2: argument 2
-// op: operation
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*! Generates a failure when a1 is not <= a2. This test is for C scalars.
+ @param a1 argument 1
+ @param a2 argument 2
+ @param op operation
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertLessThanOrEqual(a1, a2, description, ...) \
GHAssertOperation(a1, a2, <=, description, ##__VA_ARGS__)
-// Generates a failure when string a1 is not equal to string a2. This call
-// differs from GHAssertEqualObjects in that strings that are different in
-// composition (precomposed vs decomposed) will compare equal if their final
-// representation is equal.
-// ex O + umlaut decomposed is the same as O + umlaut composed.
-// Args:
-// a1: string 1
-// a2: string 2
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when string a1 is not equal to string a2. This call
+ differs from GHAssertEqualObjects in that strings that are different in
+ composition (precomposed vs decomposed) will compare equal if their final
+ representation is equal.
+ ex O + umlaut decomposed is the same as O + umlaut composed.
+ @param a1 string 1
+ @param a2 string 2
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertEqualStrings(a1, a2, description, ...) \
do { \
@try {\
@@ -402,17 +407,17 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when string a1 is equal to string a2. This call
-// differs from GHAssertEqualObjects in that strings that are different in
-// composition (precomposed vs decomposed) will compare equal if their final
-// representation is equal.
-// ex O + umlaut decomposed is the same as O + umlaut composed.
-// Args:
-// a1: string 1
-// a2: string 2
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when string a1 is equal to string a2. This call
+ differs from GHAssertEqualObjects in that strings that are different in
+ composition (precomposed vs decomposed) will compare equal if their final
+ representation is equal.
+ ex O + umlaut decomposed is the same as O + umlaut composed.
+ @param a1 string 1
+ @param a2 string 2
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertNotEqualStrings(a1, a2, description, ...) \
do { \
@try {\
@@ -424,7 +429,7 @@ if (([a1value isKindOfClass:[NSString class]] && \
(a1value == nil && [a2value isKindOfClass:[NSString class]]) || \
(a2value == nil && [a1value isKindOfClass:[NSString class]]) \
) continue; \
-[self failWithException:[NSException ghu_failureInEqualityBetweenObject: a1value \
+[self failWithException:[NSException ghu_failureInInequalityBetweenObject: a1value \
andObject: a2value \
inFile: [NSString stringWithUTF8String:__FILE__] \
atLine: __LINE__ \
@@ -439,13 +444,13 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when c-string a1 is not equal to c-string a2.
-// Args:
-// a1: string 1
-// a2: string 2
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when c-string a1 is not equal to c-string a2.
+ @param a1 string 1
+ @param a2 string 2
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertEqualCStrings(a1, a2, description, ...) \
do { \
@try {\
@@ -468,13 +473,13 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
-// Generates a failure when c-string a1 is equal to c-string a2.
-// Args:
-// a1: string 1
-// a2: string 2
-// description: A format string as in the printf() function. Can be nil or
-// an empty string but must be present.
-// ...: A variable number of arguments to the format string. Can be absent.
+/*!
+ Generates a failure when c-string a1 is equal to c-string a2.
+ @param a1 string 1
+ @param a2 string 2
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present.
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertNotEqualCStrings(a1, a2, description, ...) \
do { \
@try {\
@@ -499,14 +504,13 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
// GTM_END
// SENTE_BEGIN
-/*" Generates a failure when !{ [a1 isEqualTo:a2] } is false
+/*! Generates a failure when !{ [a1 isEqualTo:a2] } is false
(or one is nil and the other is not).
- _{a1 The object on the left.}
- _{a2 The object on the right.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+ @param a1 The object on the left
+ @param a2 The object on the right
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertEqualObjects(a1, a2, description, ...) \
do { \
@try {\
@@ -532,14 +536,13 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
} while(0)
-/*" Generates a failure when a1 is not equal to a2. This test is for
+/*! Generates a failure when a1 is not equal to a2. This test is for
C scalars, structs and unions.
- _{a1 The argument on the left.}
- _{a2 The argument on the right.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+ @param a1 The argument on the left
+ @param a2 The argument on the right
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertEquals(a1, a2, description, ...) \
do { \
@try {\
@@ -571,21 +574,20 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
}\
} while(0)
+//! Absolute difference
#define GHAbsoluteDifference(left,right) (MAX(left,right)-MIN(left,right))
-/*" Generates a failure when a1 is not equal to a2 within + or - accuracy is false.
+/*!
+ Generates a failure when a1 is not equal to a2 within + or - accuracy is false.
This test is for scalars such as floats and doubles where small differences
could make these items not exactly equal, but also works for all scalars.
- _{a1 The scalar on the left.}
- _{a2 The scalar on the right.}
- _{accuracy The maximum difference between a1 and a2 for these values to be
- considered equal.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
-
+ @param a1 The scalar on the left
+ @param a2 The scalar on the right
+ @param accuracy The maximum difference between a1 and a2 for these values to be considered equal
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertEqualsWithAccuracy(a1, a2, accuracy, description, ...) \
do { \
@try {\
@@ -621,11 +623,10 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
-/*" Generates a failure unconditionally.
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+/*! Generates a failure unconditionally.
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHFail(description, ...) \
[self failWithException:[NSException ghu_failureInFile: [NSString stringWithUTF8String:__FILE__] \
atLine: __LINE__ \
@@ -633,12 +634,11 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]
-/*" Generates a failure when a1 is not nil.
- _{a1 An object.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+/*! Generates a failure when a1 is not nil.
+ @param a1 An object
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertNil(a1, description, ...) \
do { \
@try {\
@@ -663,12 +663,11 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
} while(0)
-/*" Generates a failure when a1 is nil.
- _{a1 An object.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+/*! Generates a failure when a1 is nil.
+ @param a1 An object
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertNotNil(a1, description, ...) \
do { \
@try {\
@@ -693,12 +692,12 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
} while(0)
-/*" Generates a failure when expression evaluates to false.
- _{expr The expression that is tested.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+/*!
+ Generates a failure when expression evaluates to false.
+ @param expr The expression that is tested
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertTrue(expr, description, ...) \
do { \
BOOL _evaluatedExpression = (expr);\
@@ -713,13 +712,14 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when expression evaluates to false and in addition will
+/*!
+ Generates a failure when expression evaluates to false and in addition will
generate error messages if an exception is encountered.
- _{expr The expression that is tested.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+
+ @param expr The expression that is tested
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertTrueNoThrow(expr, description, ...) \
do { \
@try {\
@@ -743,12 +743,11 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when the expression evaluates to true.
- _{expr The expression that is tested.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+/*! Generates a failure when the expression evaluates to true.
+ @param expr The expression that is tested
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertFalse(expr, description, ...) \
do { \
BOOL _evaluatedExpression = (expr);\
@@ -763,13 +762,12 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when the expression evaluates to true and in addition
+/*! Generates a failure when the expression evaluates to true and in addition
will generate error messages if an exception is encountered.
- _{expr The expression that is tested.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+ @param expr The expression that is tested
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertFalseNoThrow(expr, description, ...) \
do { \
@try {\
@@ -793,12 +791,11 @@ withDescription:GHComposeString(description, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when expression does not throw an exception.
- _{expression The expression that is evaluated.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.
- "*/
+/*! Generates a failure when expression does not throw an exception.
+ @param expression The expression that is evaluated
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent.
+ */
#define GHAssertThrows(expr, description, ...) \
do { \
@try { \
@@ -815,14 +812,13 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when expression does not throw an exception of a
+/*! Generates a failure when expression does not throw an exception of a
specific class.
- _{expression The expression that is evaluated.}
- _{specificException The specified class of the exception.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+ @param expression The expression that is evaluated
+ @param specificException The specified class of the exception
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertThrowsSpecific(expr, specificException, description, ...) \
do { \
@try { \
@@ -849,18 +845,16 @@ withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when expression does not throw an exception of a
+/*! Generates a failure when expression does not throw an exception of a
specific class with a specific name. Useful for those frameworks like
AppKit or Foundation that throw generic NSException w/specific names
(NSInvalidArgumentException, etc).
- _{expression The expression that is evaluated.}
- _{specificException The specified class of the exception.}
- _{aName The name of the specified exception.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
-
- "*/
+ @param expression The expression that is evaluated
+ @param specificException The specified class of the exception
+ @param aName The name of the specified exception
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertThrowsSpecificNamed(expr, specificException, aName, description, ...) \
do { \
@try { \
@@ -897,12 +891,11 @@ withDescription: GHComposeString(_descrip, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when expression does throw an exception.
- _{expression The expression that is evaluated.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+/*! Generates a failure when expression does throw an exception.
+ @param expression The expression that is evaluated
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertNoThrow(expr, description, ...) \
do { \
@try { \
@@ -918,14 +911,13 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when expression does throw an exception of the specitied
+/*! Generates a failure when expression does throw an exception of the specitied
class. Any other exception is okay (i.e. does not generate a failure).
- _{expression The expression that is evaluated.}
- _{specificException The specified class of the exception.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
- "*/
+ @param expression The expression that is evaluated
+ @param specificException The specified class of the exception
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertNoThrowSpecific(expr, specificException, description, ...) \
do { \
@try { \
@@ -944,18 +936,16 @@ withDescription: GHComposeString(description, ##__VA_ARGS__)]]; \
} while (0)
-/*" Generates a failure when expression does throw an exception of a
+/*! Generates a failure when expression does throw an exception of a
specific class with a specific name. Useful for those frameworks like
AppKit or Foundation that throw generic NSException w/specific names
(NSInvalidArgumentException, etc).
- _{expression The expression that is evaluated.}
- _{specificException The specified class of the exception.}
- _{aName The name of the specified exception.}
- _{description A format string as in the printf() function. Can be nil or
- an empty string but must be present.}
- _{... A variable number of arguments to the format string. Can be absent.}
-
- "*/
+ @param expression The expression that is evaluated.
+ @param specificException The specified class of the exception
+ @param aName The name of the specified exception
+ @param description A format string as in the printf() function. Can be nil or an empty string but must be present
+ @param ... A variable number of arguments to the format string. Can be absent
+ */
#define GHAssertNoThrowSpecificNamed(expr, specificException, aName, description, ...) \
do { \
@try { \
@@ -979,7 +969,9 @@ continue; \
} while (0)
-@interface NSException (GHTestMacros_GTMSenTestAdditions)
+//! @cond DEV
+
+@interface NSException(GHTestMacros_GTMSenTestAdditions)
+ (NSException *)ghu_failureInFile:(NSString *)filename
atLine:(int)lineNumber
withDescription:(NSString *)formatString, ...;
@@ -993,6 +985,11 @@ continue; \
inFile:(NSString *)filename
atLine:(int)lineNumber
withDescription:(NSString *)formatString, ...;
++ (NSException *)ghu_failureInInequalityBetweenObject:(id)left
+ andObject:(id)right
+ inFile:(NSString *)filename
+ atLine:(int)lineNumber
+ withDescription:(NSString *)formatString, ...;
+ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left
andValue:(NSValue *)right
withAccuracy:(NSValue *)accuracy
@@ -1010,4 +1007,6 @@ continue; \
withDescription:(NSString *)formatString, ...;
@end
+//! @endcond
+
// SENTE_END
View
6 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestOperation.h
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import "GHTest.h"
/*!
@@ -39,4 +41,6 @@
- (id)initWithTest:(id<GHTest>)test options:(GHTestOptions)options;
-@end
+@end
+
+//! @endcond
View
3  Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestRunner.h
@@ -26,6 +26,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
//
// Portions of this file fall under the following license, marked with:
// GTM_BEGIN : GTM_END
@@ -156,4 +158,5 @@
@end
+//! @endcond
View
4 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestSuite.h
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import "GHTestGroup.h"
/*!
@@ -112,3 +114,5 @@ extern NSString *GHUnitTest;
- (BOOL)writeJUnitXML:(NSError **)error;
@end
+
+//! @endcond
View
6 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestViewModel.h
@@ -1,6 +1,6 @@
//
// GHTest.h
-// GHKit
+// GHUnit
//
// Created by Gabriel Handford on 1/17/09.
// Copyright 2009. All rights reserved.
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
#import "GHTestGroup.h"
@class GHTestNode;
@@ -161,3 +163,5 @@ typedef enum {
- (void)setFilter:(GHTestNodeFilter)filter textFilter:(NSString *)textFilter;
@end
+
+//! @endcond
View
4 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTesting.h
@@ -27,6 +27,8 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
+//! @cond DEV
+
//
// Portions of this file fall under the following license, marked with:
// GTM_BEGIN : GTM_END
@@ -142,3 +144,5 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
@protocol GHSenTestCase
- (void)raiseAfterFailure;
@end
+
+//! @endcond
View
6 ...es/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHUNSObject+Swizzle.h
@@ -27,10 +27,14 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-@interface NSObject (GHUSwizzle)
+//! @cond DEV
+
+@interface NSObject(GHUSwizzle)
+ (void)ghu_swizzleMethod:(SEL)original withMethod:(SEL)alternate;
+ (void)ghu_swizzleClassMethod:(SEL)original withClassMethod:(SEL)alternate;
@end
+//! @endcond
+
View
541 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHUnit.h
@@ -42,10 +42,549 @@
#import "NSException+GHTestFailureExceptions.h"
#import "NSValue+GHValueFormatter.h"
+#if TARGET_OS_IPHONE
+#import "GHUnitIPhoneAppDelegate.h"
+#endif
+
#ifdef DEBUG
#define GHUDebug(fmt, ...) do { \
fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@"\n"] UTF8String], stdout); \
} while(0)
#else
#define GHUDebug(fmt, ...) do {} while(0)
-#endif
+#endif
+
+/*!
+ @mainpage GHUnit
+
+
+ GHUnit is a test framework for Objective-C (Mac OS X 10.5 and above and iPhone 3.x and above).
+ It can be used with SenTestingKit, GTM or all by itself.
+
+ For example, your test cases will be run if they subclass any of the following:
+
+ - GHTestCase
+ - SenTestCase
+ - GTMTestCase
+
+
+ Source: http://github.com/gabriel/gh-unit
+
+ View docs online: http://gabriel.github.com/gh-unit/
+
+
+ This manual is divided in the following sections:
+ - @subpage Examples
+ - @subpage Installing
+ - @subpage Building
+ - @subpage TestMacros
+ - @subpage EnvVariables
+ - @subpage CommandLine "Command Line & Makefiles"
+ - @subpage Customizing
+ - @subpage Hudson
+
+
+ @image html http://rel.me.s3.amazonaws.com/gh-unit/images/GHUnit-IPhone-0.4.18.png
+
+ @image html http://rel.me.s3.amazonaws.com/gh-unit/images/GHUnit-0.4.18.png
+
+ @section Notes Notes
+
+ GHUnit was inspired by and uses parts of GTM (google-toolbox-for-mac) code, mostly from UnitTesting: http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/UnitTesting/
+
+ */
+
+/*!
+ @page Installing Installing
+
+ - @ref InstallingIOS
+ - @ref InstallMacOSX
+
+ @section InstallingIOS Installing (iOS)
+
+ - Add a <tt>New Target</tt>. Select <tt>Cocoa Touch -> Application</tt>. Name it <tt>Tests</tt> (or something similar).
+ - Add the <tt>GHUnitIOS.framework</tt> to your project.
+ - Add the following frameworks to <tt>Linked Libraries</tt>:
+ - <tt>GHUnitIOS.framework</tt>
+ - <tt>CoreGraphics.framework</tt>
+ - <tt>Foundation.framework</tt>
+ - <tt>UIKit.framework</tt>
+ - Under 'Framework Search Paths' make sure the (parent) directory to GHUnit.framework is listed.
+ - Under 'Other Linker Flags' in the <tt>Tests</tt> target, add <tt>-ObjC</tt> and <tt>-all_load</tt>
+ - By default, the Tests-Info.plist file includes <tt>MainWindow</tt> for <tt>Main nib file base name</tt>. You should clear this field.
+ - Add the GHUnitIOSTestMain.m (http://github.com/gabriel/gh-unit/blob/master/Project-IPhone/GHUnitIOSTestMain.m) file into your project.
+ - (Optional) Create and and set a prefix header (<tt>Tests_Prefix.pch</tt>) and add <tt>#import <GHUnitIOS/GHUnit.h></tt> to it, and then you won't have to include that import for every test.
+ - (Optional) @ref Makefile "Install Makefile"
+ - @ref Examples "Create a test"
+
+ Now you can create a test (either by subclassing <tt>SenTestCase</tt> or <tt>GHTestCase</tt>), adding it to your test target.
+
+ @section InstallMacOSX Installing (Mac OS X)
+
+ You can install it globally in /Library/Frameworks or with a little extra effort embed it with your project.
+
+ @subsection InstallLibraryFrameworks Installing in /Library/Frameworks
+
+ - Copy <tt>GHUnit.framework</tt> to <tt>/Library/Frameworks/</tt>
+ - Add a <tt>New Target</tt>. Select <tt>Cocoa -> Application</tt>. Name it <tt>Tests</tt> (or something similar).
+ - In the <tt>Target 'Tests' Info</tt> window, <tt>General</tt> tab:
+ - Add a linked library, under <tt>Mac OS X 10.X SDK</tt> section, select <tt>GHUnit.framework</tt>
+ - If your main target is a library: Add a linked library, and select your main target.
+ - If your main target is an application, you will need to include these source files in the <tt>Test</tt> project manually.
+ - Add a direct dependency, and select your project. (This will cause your application or framework to build before the test target.)
+ - Copy GHUnitTestMain.m (http://github.com/gabriel/gh-unit/tree/master/Classes-MacOSX/GHUnitTestMain.m) into your project and include in the Test target.
+ - Now create a test (either by subclassing <tt>SenTestCase</tt> or <tt>GHTestCase</tt>), adding it to your test target. (See example test case below.)
+ - By default, the Tests-Info.plist file includes <tt>MainWindow</tt> for <tt>Main nib file base name</tt>. You should clear this field.
+ - (Optional) @ref Makefile "Install Makefile"
+ - @ref Examples "Create a test"
+
+ @subsection InstallProject Installing in your project
+
+ - Add a <tt>New Target</tt>. Select <tt>Cocoa -> Application</tt>. Name it <tt>Tests</tt> (or something similar).
+ - In the Finder, copy <tt>GHUnit.framework</tt> to your project directory (maybe in MyProject/Frameworks/.)
+ - In the <tt>Tests</tt> target, add the <tt>GHUnit.framework</tt> files (from MyProject/Frameworks/). It should now be visible as a <tt>Linked Framework</tt> in the target.
+ - In the <tt>Tests</tt> target, under Build Settings, add <tt>@loader_path/../Frameworks</tt> to <tt>Runpath Search Paths</tt> (Under All Configurations)
+ - In the <tt>Tests</tt> target, add <tt>New Build Phase</tt> | <tt>New Copy Files Build Phase</tt>.
+ - Change the Destination to <tt>Frameworks</tt>.
+ - Drag <tt>GHUnit.framework</tt> into the the build phase
+ - Make sure the copy phase appears before any <tt>Run Script</tt> phases
+ - Copy GHUnitTestMain.m (http://github.com/gabriel/gh-unit/tree/master/Classes-MacOSX/GHUnitTestMain.m) into your project and include in the Test target.
+
+ - If your main target is a library:
+ - In the <tt>Target 'Tests' Info</tt> window, <tt>General</tt> 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.
+ - If your main target is an application, you will need to include these source files to the <tt>Test</tt> project manually.
+
+ - Now create a test (either by subclassing <tt>SenTestCase</tt> or <tt>GHTestCase</tt>), adding it to your test target. (See example test case below.)
+ - By default, the Tests-Info.plist file includes <tt>MainWindow</tt> for <tt>Main nib file base name</tt>. You should clear this field.
+ - (Optional) @ref Makefile "Install Makefile"
+ - @ref Examples "Create a test"
+ */
+
+/*!
+ @page Building Building
+
+ For iOS, run <tt>make</tt> from within the <tt>Project-IPhone</tt> directory. The framework is in <tt>Project-IPhone/build/Framework/</tt>.
+
+ For Mac OS X, the framework build is stored in <tt>Project/build/Release/</tt>.
+ */
+
+/*!
+ @page Examples Examples
+
+ - @ref ExampleTestCase
+ - @ref ExampleAsyncTestCase
+
+ @section ExampleTestCase Example Test Case
+
+ For example <tt>ExampleTest.m</tt>:
+
+ @code
+ // For iOS
+ #import <GHUnitIOS/GHUnit.h>
+ // For Mac OS X
+ //#import <GHUnit/GHUnit.h>
+
+ @interface ExampleTest : GHTestCase { }
+ @end
+
+ @implementation ExampleTest
+
+ - (BOOL)shouldRunOnMainThread {
+ // By default NO, but if you have a UI test or test dependent on running on the main thread return YES
+ return NO;
+ }
+
+ - (void)setUpClass {
+ // Run at start of all tests in the class
+ }
+
+ - (void)tearDownClass {
+ // Run at end of all tests in the class
+ }
+
+ - (void)setUp {
+ // Run before each test method
+ }
+
+ - (void)tearDown {
+ // Run after each test method
+ }
+
+ - (void)testFoo {
+ NSString *a = @"foo";
+ GHTestLog(@"I can log to the GHUnit test console: %@", a);
+
+ // Assert a is not NULL, with no custom error description
+ GHAssertNotNULL(a, nil);
+
+ // Assert equal objects, add custom error description
+ NSString *b = @"bar";
+ GHAssertEqualObjects(a, b, @"A custom error message. a should be equal to: %@.", b);
+ }
+
+ - (void)testBar {
+ // Another test
+ }
+
+ @end
+ @endcode
+
+ @section ExampleAsyncTestCase Example Async Test Case
+
+ @code
+ // For iOS
+ #import <GHUnitIOS/GHUnit.h>
+ // For Mac OS X
+ //#import <GHUnit/GHUnit.h>
+
+ @interface ExampleAsyncTest : GHAsyncTestCase { }
+ @end
+
+ @implementation ExampleAsyncTest
+
+ - (void)testURLConnection {
+
+ // Call prepare to setup the asynchronous action.
+ // This helps in cases where the action is synchronous and the
+ // action occurs before the wait is actually called.
+ [self prepare];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]];
+ NSURLConnection *connection = [[NSURLConnection alloc] initWithRequest:request delegate:self startImmediately:YES];
+
+ // Wait until notify called for timeout (seconds); If notify is not called with kGHUnitWaitStatusSuccess then
+ // we will throw an error.
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:10.0];
+
+ [connection release];
+ }
+
+ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
+ // Notify of success, specifying the method where wait is called.
+ // This prevents stray notifies from affecting other tests.
+ [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testURLConnection)];
+ }
+
+ - (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
+ // Notify of connection failure
+ [self notify:kGHUnitWaitStatusFailure forSelector:@selector(testURLConnection)];
+ }
+
+ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
+ GHTestLog(@"%@", [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease]);
+ }
+
+ @end
+ @endcode
+
+
+ @section ExampleProjects Example Projects
+
+ Example projects can be found at: http://github.com/gabriel/gh-unit/tree/master/Examples/
+
+ */
+
+/*!
+ @page EnvVariables Environment Variables
+
+ @section GHUnitEnvVariables GHUnit Environment Variables
+
+ Go into the "Get Info" contextual menu of your (Tests) executable (inside the "Executables" group in the left panel of XCode).
+ Then go in the "Arguments" tab. You can add the following environment variables:
+
+ @verbatim
+ GHUNIT_CLI - Default NO; Runs tests on the command line (see Debugger Console, Cmd-Shift-R)
+ GHUNIT_RERAISE - Default NO; If an exception is encountered it re-raises it allowing you to crash into the debugger
+ GHUNIT_AUTORUN - Default NO; If YES, tests will start automatically
+ GHUNIT_AUTOEXIT - Default NO; If YES, will exit upon test completion (no matter what); For command line MacOSX testing
+ @endverbatim
+
+
+ @section EnvVariablesTest Test Environment Variables (Recommended)
+
+ Go into the "Get Info" contextual menu of your (Tests) executable (inside the "Executables" group in the left panel of XCode).
+ Then go in the "Arguments" tab. You can add the following environment variables:
+
+ @verbatim
+ Environment Variable: Default: Set to:
+ NSDebugEnabled NO YES
+ NSZombieEnabled NO YES
+ NSDeallocateZombies NO NO (or YES)
+ NSHangOnUncaughtException NO YES
+ NSAutoreleaseFreedObjectCheckEnabled NO YES
+ @endverbatim
+
+ If Using NSDeallocateZombies=NO, then all objects will leak so be sure to turn it off when debugging memory leaks.
+
+ For more info on these varaiables see NSDebug.h (http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html)
+
+ For malloc debugging:
+
+ @verbatim
+ MallocStackLogging
+ MallocStackLoggingNoCompact
+ MallocScribble
+ MallocPreScribble
+ MallocGuardEdges
+ MallocDoNotProtectPrelude
+ MallocDoNotProtectPostlude
+ MallocCheckHeapStart
+ MallocCheckHeapEach
+ @endverbatim
+
+ If you see a message like:
+
+ @verbatim
+ 2009-10-15 13:02:24.746 Tests[38615:40b] *** -[Foo class]: message sent to deallocated instance 0x1c8e680
+ @endverbatim
+
+ Re-run (in gdb) with <tt>MallocStackLogging=YES</tt> (or <tt>MallocStackLoggingNoCompact=YES</tt>), then if you run under gdb:
+
+ @verbatim
+ (gdb) shell malloc_history 38615 0x1c8e680
+
+ ALLOC 0x1a9ad10-0x1a9ad6f [size=96]: thread_a024a500 |start | main | UIApplicationMain | GSEventRun | GSEventRunModal | CFRunLoopRunInMode | CFRunLoopRunSpecific | __NSThreadPerformPerform | -[GHTestGroup _run:] | -[GHTest run] | +[GHTesting runTest:selector:withObject:exception:interval:] | -[Foo foo] | +[NSObject alloc] | +[NSObject allocWithZone:] | _internal_class_createInstance | _internal_class_createInstanceFromZone | calloc | malloc_zone_calloc
+
+ @endverbatim
+
+ Somewhere between runTest and NSObject alloc there may be an object that wasn't retained.
+
+ Also using <tt>MallocScribble=YES</tt> causes the malloc library to overwrite freed memory with a well-known value (0x55), and occasionally checks freed malloc blocks to make sure the memory has not been over-written overwritten written since it was cleared.
+
+ For more info on these variables see MallocDebug (http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html)
+
+ For more info on malloc_history see malloc_history (http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/man1/malloc_history.1.html)
+
+ */
+
+/*!
+
+ @page CommandLine Command Line
+
+ @section CommandLineRunningTests Running Tests
+
+ To run the tests from the command line:
+
+ - Copy the RunTests.sh (http://github.com/gabriel/gh-unit/tree/master/Scripts/RunTests.sh) file into your project directory (if you haven't already).
+ - In XCode:
+ - To the <tt>Tests</tt> target, Add <tt>New Build Phase</tt> | <tt>New Run Script Build Phase</tt>
+ - Enter <tt>sh RunTests.sh</tt> as the script. The path to <tt>RunTests.sh</tt> should be relative to the xcode project file (.xcodeproj)!
+ - (Optional) Uncheck 'Show environment variables in build log'
+
+ From the command line, run the tests from xcodebuild (with the GHUNIT_CLI environment variable set):
+
+ @verbatim
+ // For mac app; This might seg fault in 10.6, in which case you should use make test via Makefile below
+ GHUNIT_CLI=1 xcodebuild -target Tests -configuration Debug -sdk macosx10.5 build
+
+ // For iPhone app
+ GHUNIT_CLI=1 xcodebuild -target Tests -configuration Debug -sdk iphonesimulator4.0 build
+ @endverbatim
+
+ If you are wondering, the <tt>RunTests.sh</tt> script will only run the tests if the env variable GHUNIT_CLI is set.
+ This is why this RunScript phase is ignored when running the test GUI. This is how we use a single Test target for both the GUI and command line testing.
+
+ This may seem strange that we run via xcodebuild with a RunScript phase in order to work on the command line, but otherwise we may not have
+ the environment settings or other XCode specific configuration right.
+
+ @section Makefile Makefile
+
+ Follow the directions above for adding command line support.
+
+ Example Makefile's for Mac or iPhone apps:
+
+ - Makefile (Mac OS X): http://github.com/gabriel/gh-unit/tree/master/Project/Makefile (for a Mac App)
+ - Makefile (iOS): http://github.com/gabriel/gh-unit/tree/master/Project-IPhone/Makefile (for an iPhone App)
+
+ The script will return a non-zero exit code on test failure.
+
+ To run the tests via the Makefile:
+
+ @verbatim
+ make test
+ @endverbatim
+
+ @section RunningATest Running a Test Case / Single Test
+
+ The <tt>TEST</tt> environment variable can be used to run a single test or test case.
+
+ @verbatim
+ // Run all tests in GHSlowTest
+ make test TEST="GHSlowTest"
+
+ // Run the method testSlowA in GHSlowTest
+ make test TEST="GHSlowTest/testSlowA"
+ @endverbatim
+
+ */
+
+/*!
+