Permalink
Browse files

Fixing MacOSX tests

  • Loading branch information...
1 parent 7a779b0 commit 546fed032f4d5d0f065af5d222c26f9c36782715 @johnboiles johnboiles committed Oct 27, 2011
Showing with 506 additions and 821 deletions.
  1. +1 −1 Classes-MacOSX/UI/GHTestViewController.m
  2. +0 −1 Classes/GHTestCase.h
  3. BIN Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/GHUnit
  4. +52 −44 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHAsyncTestCase.h
  5. +2 −6 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHMockNSHTTPURLResponse.h
  6. +42 −48 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHMockNSURLConnection.h
  7. +14 −11 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHNSLocale+Mock.h
  8. +1 −1 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTest+JUnitXML.h
  9. +100 −13 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTest.h
  10. +49 −43 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestCase.h
  11. +23 −12 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestGroup.h
  12. +54 −19 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestMacros.h
  13. +5 −4 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestOperation.h
  14. +77 −18 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestRunner.h
  15. +3 −3 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestSuite.h
  16. +58 −9 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestViewModel.h
  17. +14 −7 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHTesting.h
  18. +1 −574 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Headers/GHUnit.h
  19. BIN Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestApp.nib
  20. BIN Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestView.nib
  21. BIN Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestWindow.nib
  22. +7 −7 Examples/MyTestable-MacOSX/Frameworks/GHUnit.framework/Versions/A/Resources/Info.plist
  23. +3 −0 Project-MacOSX/GHUnitMacOSX.xcodeproj/project.pbxproj
@@ -349,7 +349,7 @@ - (void)selectRow:(NSInteger)row {
}
- (void)_updateTest:(id<GHTest>)test {
- GHTestNode *testNode = [dataSource_ findTestNode:test];
+ GHTestNode *testNode = [dataSource_ findTestNodeForTest:test];
[_outlineView reloadItem:testNode];
NSInteger runCount = [suite_ stats].succeedCount + [suite_ stats].failureCount;
View
@@ -48,7 +48,6 @@
#import "GHTestMacros.h"
#import "GHTest.h"
-#import "UIKit/UIKit.h"
/*!
Log to your test case logger. For example,
@@ -29,12 +29,14 @@
#import "GHTestCase.h"
-// Some default statuses to use; Or define and use your own
+/*!
+ Common wait statuses to use with waitForStatus:timeout:.
+ */
enum {
- kGHUnitWaitStatusUnknown = 0, //!< Unknown wait status
- kGHUnitWaitStatusSuccess, //!< Wait status success
- kGHUnitWaitStatusFailure, //!< Wait status failure
- kGHUnitWaitStatusCancelled //!< Wait status cancelled
+ kGHUnitWaitStatusUnknown = 0, // Unknown wait status
+ kGHUnitWaitStatusSuccess, // Wait status success
+ kGHUnitWaitStatusFailure, // Wait status failure
+ kGHUnitWaitStatusCancelled // Wait status cancelled
};
/*!
@@ -45,31 +47,31 @@ 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];
-
- // Do asynchronous task here
- [self performSelector:@selector(_succeed) withObject:nil afterDelay:0.1];
-
- [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
- }
-
- - (void)_succeed {
- // Notice the forSelector points to the test above. This is so that
- // stray notifies don't error or falsely succeed other tests.
- // To ignore the check, forSelector can be NULL.
- [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testSuccess)];
- }
-
- @end
- @endcode
+ @interface MyAsyncTest : GHAsyncTestCase { }
+ @end
+
+ @implementation MyAsyncTest
+
+ - (void)testSuccess {
+ // Prepare for asynchronous call
+ [self prepare];
+
+ // Do asynchronous task here
+ [self performSelector:@selector(_succeed) withObject:nil afterDelay:0.1];
+
+ // Wait for notify
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
+ }
+
+ - (void)_succeed {
+ // Notify the wait. Notice the forSelector points to the test above.
+ // This is so that stray notifies don't error or falsely succeed other tests.
+ // To ignore the check, forSelector can be NULL.
+ [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testSuccess)];
+ }
+
+ @end
+
*/
@interface GHAsyncTestCase : GHTestCase {
@@ -96,7 +98,8 @@ enum {
/*!
Prepare and specify the selector we will use in notify.
- @param selector
+
+ @param selector Selector
*/
- (void)prepare:(SEL)selector;
@@ -106,48 +109,53 @@ enum {
Be sure to prepare before calling your asynchronous method.
For example,
- @code
- - (void)testFoo {
- [self prepare];
- // Do asynchronous task here
- [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
- }
- @endcode
+ - (void)testFoo {
+ [self prepare];
+
+ // Do asynchronous task here
+
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
+ }
@param status kGHUnitWaitStatusSuccess, kGHUnitWaitStatusFailure or custom status
@param timeout Timeout in seconds
*/
- (void)waitForStatus:(NSInteger)status timeout:(NSTimeInterval)timeout;
/*!
- @deprecated
+ @param status kGHUnitWaitStatusSuccess, kGHUnitWaitStatusFailure or custom status
+ @param timeout Timeout in seconds
+ @deprecated Use waitForTimeout:
*/
- (void)waitFor:(NSInteger)status timeout:(NSTimeInterval)timeout;
/*!
Wait for timeout to occur.
Fails if we did _NOT_ timeout.
- @param timeout
+
+ @param timeout Timeout
*/
- (void)waitForTimeout:(NSTimeInterval)timeout;
/*!
Notify waiting of status for test selector.
+
@param status Status, for example, kGHUnitWaitStatusSuccess
- @param selector If not NULL, then will verify this selector is where we are waiting.
- This prevents stray asynchronous callbacks to fail a later test
+ @param selector If not NULL, then will verify this selector is where we are waiting. This prevents stray asynchronous callbacks to fail a later test.
*/
- (void)notify:(NSInteger)status forSelector:(SEL)selector;
/*!
Notify waiting of status for any selector.
+
@param status Status, for example, kGHUnitWaitStatusSuccess
*/
- (void)notify:(NSInteger)status;
/*!
- Run the run loops for the specified interval.
- @param interval
+ Run the run loops for the specified interval.
+
+ @param interval Interval
@author Adapted from Robert Palmer, pauseForTimeout
*/
- (void)runForInterval:(NSTimeInterval)interval;
@@ -27,12 +27,10 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-//! @cond DEV
-
#import <Foundation/Foundation.h>
-/*!
- NSHTTPURLResponse for use with mocking.
+/*
+ NSHTTPURLResponse subclass for use with mocking.
Allows us to manually set the status code and headers in the response.
*/
@interface GHMockNSHTTPURLResponse : NSHTTPURLResponse {
@@ -46,5 +44,3 @@
- (void)setHeaders:(NSDictionary *)headers;
@end
-
-//! @endcond
@@ -27,8 +27,6 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-//! @cond DEV
-
#import <Foundation/Foundation.h>
extern NSString *const GHMockNSURLConnectionException;
@@ -38,37 +36,34 @@ extern NSString *const GHMockNSURLConnectionException;
Use with GHAsyncTestCase to mock out connections.
- @code
-
- @interface GHNSURLConnectionMockTest : GHAsyncTestCase {}
- @end
-
- @implementation GHNSURLConnectionMockTest
-
- - (void)testMock {
- [self prepare];
- GHMockNSURLConnection *connection = [[GHMockNSURLConnection alloc] initWithRequest:nil delegate:self];
- [connection receiveHTTPResponseWithStatusCode:204 headers:testHeaders_ afterDelay:0.1];
- [connection receiveData:testData_ afterDelay:0.2];
- [connection finishAfterDelay:0.3];
- [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
- }
-
- - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
- GHAssertEquals([(NSHTTPURLResponse *)response statusCode], 204, nil);
- GHAssertEqualObjects([(NSHTTPURLResponse *)response allHeaderFields], testHeaders_, nil);
- }
-
- - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
- GHAssertEqualObjects(data, testData_, nil);
- }
-
- - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
- [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testMock)];
- }
- @end
-
- @endcode
+ @interface GHNSURLConnectionMockTest : GHAsyncTestCase {}
+ @end
+
+ @implementation GHNSURLConnectionMockTest
+
+ - (void)testMock {
+ [self prepare];
+ GHMockNSURLConnection *connection = [[GHMockNSURLConnection alloc] initWithRequest:nil delegate:self];
+ [connection receiveHTTPResponseWithStatusCode:204 headers:testHeaders_ afterDelay:0.1];
+ [connection receiveData:testData_ afterDelay:0.2];
+ [connection finishAfterDelay:0.3];
+ [self waitForStatus:kGHUnitWaitStatusSuccess timeout:1.0];
+ }
+
+ - (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
+ GHAssertEquals([(NSHTTPURLResponse *)response statusCode], 204, nil);
+ GHAssertEqualObjects([(NSHTTPURLResponse *)response allHeaderFields], testHeaders_, nil);
+ }
+
+ - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
+ GHAssertEqualObjects(data, testData_, nil);
+ }
+
+ - (void)connectionDidFinishLoading:(NSURLConnection *)connection {
+ [self notify:kGHUnitWaitStatusSuccess forSelector:@selector(testMock)];
+ }
+ @end
+
*/
@interface GHMockNSURLConnection : NSObject {
NSURLRequest *request_;
@@ -96,26 +91,27 @@ extern NSString *const GHMockNSURLConnectionException;
/*!
Send generic response to delegate after delay.
(For asynchronous requests)
- @param delay Delay in seconds (if < 0, there is no delay)
+ @param response Response
+ @param afterDelay Delay in seconds (if < 0, there is no delay)
*/
-- (void)receiveResponse:(NSURLResponse *)response afterDelay:(NSTimeInterval)delay;
+- (void)receiveResponse:(NSURLResponse *)response afterDelay:(NSTimeInterval)afterDelay;
/*!
Send HTTP response to delegate with status code, headers, after delay.
This is only the HTTP response (and not data or finished).
(For asynchronous requests)
@param statusCode HTTP status code
@param headers Headers
- @param delay Delay in seconds (if < 0, there is no delay)
+ @param afterDelay Delay in seconds (if < 0, there is no delay)
*/
-- (void)receiveHTTPResponseWithStatusCode:(int)statusCode headers:(NSDictionary *)headers afterDelay:(NSTimeInterval)delay;
+- (void)receiveHTTPResponseWithStatusCode:(int)statusCode headers:(NSDictionary *)headers afterDelay:(NSTimeInterval)afterDelay;
/*!
Send data to connection delegate after delay.
@param data Data to send
- @param delay Delay in seconds
+ @param afterDelay Delay in seconds
*/
-- (void)receiveData:(NSData *)data afterDelay:(NSTimeInterval)delay;
+- (void)receiveData:(NSData *)data afterDelay:(NSTimeInterval)afterDelay;
/*!
Send data to connection delegate.
@@ -124,15 +120,15 @@ extern NSString *const GHMockNSURLConnectionException;
@param MIMEType Mime type
@param afterDelay Delay
*/
-- (void)receiveData:(NSData *)data statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)delay;
+- (void)receiveData:(NSData *)data statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)afterDelay;
/*!
Send data (from file in bundle resource) to connection delegate after delay.
(For asynchronous requests)
@param path Path to file
- @param delay Delay in seconds
+ @param afterDelay Delay in seconds
*/
-- (void)receiveDataFromPath:(NSString *)path afterDelay:(NSTimeInterval)delay;
+- (void)receiveDataFromPath:(NSString *)path afterDelay:(NSTimeInterval)afterDelay;
/*!
Calls connectionDidFinish: delegate after delay.
@@ -149,7 +145,7 @@ extern NSString *const GHMockNSURLConnectionException;
@param MIMEType Content type for response header
@param afterDelay Delay before responding (if < 0, there is no delay)
*/
-- (void)receiveFromPath:(NSString *)path statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)delay;
+- (void)receiveFromPath:(NSString *)path statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)afterDelay;
/*!
Sends mock response, sends data, and then calls finish.
@@ -159,15 +155,13 @@ extern NSString *const GHMockNSURLConnectionException;
@param MIMEType Content type for response header
@param afterDelay Delay before responding (if < 0, there is no delay)
*/
-- (void)receiveData:(NSData *)data statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)delay;
+- (void)receiveData:(NSData *)data statusCode:(NSInteger)statusCode MIMEType:(NSString *)MIMEType afterDelay:(NSTimeInterval)afterDelay;
/*!
Calls connection:didFailWithError: on delegate after specified delay.
@param error The error to pass to the delegate.
- @param delay Delay before responding (if < 0, there is no delay)
+ @param afterDelay Delay before responding (if < 0, there is no delay)
*/
-- (void)failWithError:(NSError *)error afterDelay:(NSTimeInterval)delay;
+- (void)failWithError:(NSError *)error afterDelay:(NSTimeInterval)afterDelay;
@end
-
-//! @endcond
@@ -27,23 +27,24 @@
// OTHER DEALINGS IN THE SOFTWARE.
//
-//! @cond DEV
-
#import <Foundation/Foundation.h>
/*!
Category for overriding the current locale at runtime.
- @code
- #import "GHNSLocale+Mock.h"
- // This aliases the currentLocale method and with the specified locale identifier
- [NSLocale gh_setLocaleIdentifier:@"en_GB"];
-
- [[NSLocale currentLocale] localeIdentifier] == "en_GB"
- @endcode
+ #import "GHNSLocale+Mock.h"
+ // This aliases the currentLocale method and with the specified locale identifier
+ [NSLocale gh_setLocaleIdentifier:@"en_GB"];
+
+ [[NSLocale currentLocale] localeIdentifier] == "en_GB"
+
*/
@interface NSLocale(GHMock)
+/*!
+ Set locale.
+ @param localeIdentifier Locale identifier, e.g. "en_US"
+ */
+ (void)gh_setLocaleIdentifier:(NSString *)localeIdentifier;
/*!
@@ -52,6 +53,10 @@
*/
+ (NSLocale *)gh_currentLocale;
+/*!
+ Set preferred languages. To reset, set to nil.
+ @param preferredLanguages Preferred languages to set
+ */
+ (void)gh_setPreferredLanguages:(NSArray *)preferredLanguages;
/*!
@@ -61,5 +66,3 @@
+ (NSArray *)gh_preferredLanguages;
@end
-
-//! @endcond
Oops, something went wrong.

0 comments on commit 546fed0

Please sign in to comment.