Permalink
Browse files

Updating GHUnit

  • Loading branch information...
1 parent 49bf67f commit e0280b5cffeb719ed49cc22b273a30ae6bfa4fc3 @gabriel committed Feb 8, 2010
Showing with 219 additions and 57 deletions.
  1. BIN Project-IPhone/Libraries/libGHUnitIPhone3_0-0.4.13/libGHUnitIPhone3_0.a
  2. 0 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHAsyncTestCase.h
  3. +37 −23 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHTest.h
  4. 0 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHTestCase.h
  5. +16 −11 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHTestGroup.h
  6. +3 −0 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHTestMacros.h
  7. +12 −6 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHTestRunner.h
  8. 0 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHTestSuite.h
  9. +33 −2 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHTesting.h
  10. 0 ...ct-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHUNSObject+Swizzle.h
  11. 0 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHUnit.h
  12. 0 ...Phone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHUnitIPhoneAppDelegate.h
  13. 0 ...t-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/GHUnitIPhoneTestMain.m
  14. +15 −0 Project-IPhone/Libraries/libGHUnitIPhone3_0-0.4.19/Makefile
  15. +5 −0 ...ies/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/NSException+GHTestFailureExceptions.h
  16. 0 ...hone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/NSValue+GHValueFormatter.h
  17. 0 Project-IPhone/Libraries/{libGHUnitIPhone3_0-0.4.13 → libGHUnitIPhone3_0-0.4.19}/RunTests.sh
  18. BIN Project-IPhone/Libraries/libGHUnitIPhone3_0-0.4.19/libGHUnitIPhone3_0.a
  19. BIN Project/Frameworks/GHUnit.framework/Versions/A/GHUnit
  20. +20 −2 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTest.h
  21. +0 −2 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestApp.h
  22. +7 −1 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestGroup.h
  23. +3 −0 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestMacros.h
  24. +12 −6 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestRunner.h
  25. +11 −0 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestViewController.h
  26. +6 −1 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTestViewModel.h
  27. +33 −2 Project/Frameworks/GHUnit.framework/Versions/A/Headers/GHTesting.h
  28. +5 −0 Project/Frameworks/GHUnit.framework/Versions/A/Headers/NSException+GHTestFailureExceptions.h
  29. BIN Project/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestApp.nib
  30. BIN Project/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestView.nib
  31. BIN Project/Frameworks/GHUnit.framework/Versions/A/Resources/GHTestWindow.nib
  32. +1 −1 Project/Frameworks/GHUnit.framework/Versions/A/Resources/Info.plist
@@ -39,13 +39,26 @@ typedef enum {
GHTestStatusErrored, // Test finished and errored
} GHTestStatus;
+enum {
+ GHTestOptionReraiseExceptions = 1 << 0, // Allows exceptions to be raised (so you can trigger the debugger)
+ GHTestOptionForceSetUpTearDownClass = 1 << 1, // Runs setUpClass/tearDownClass for this (each) test; Used when re-running a single test in a group
+};
+typedef NSInteger GHTestOptions;
+
/*!
Generate string from GHTestStatus
@param status
*/
extern NSString* NSStringFromGHTestStatus(GHTestStatus status);
+/*!
+ Check if test is running (or trying to cancel).
+ */
extern BOOL GHTestStatusIsRunning(GHTestStatus status);
+
+/*!
+ Check if test has succeeded, errored or cancelled.
+ */
extern BOOL GHTestStatusEnded(GHTestStatus status);
/*!
@@ -73,29 +86,25 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
The base interface for a runnable test.
A runnable with a unique identifier, display name, stats, timer, delegate, log and error handling.
*/
-@protocol GHTest <NSObject>
-
-- (void)run;
-
-- (NSString *)identifier;
-- (NSString *)name;
+@protocol GHTest <NSObject, NSCoding, NSCopying>
-- (NSTimeInterval)interval;
-- (GHTestStatus)status;
-- (GHTestStats)stats;
+- (void)run:(GHTestOptions)options;
-- (void)setDelegate:(id<GHTestDelegate>)delegate;
-
-- (NSException *)exception;
-- (void)setException:(NSException *)exception;
+@property (readonly, nonatomic) NSString *identifier; // Unique identifier for test
+@property (readonly, nonatomic) NSString *name;
+@property (assign, nonatomic) NSTimeInterval interval;
+@property (assign, nonatomic) GHTestStatus status;
+@property (readonly, nonatomic) GHTestStats stats;
+@property (retain, nonatomic) NSException *exception;
+@property (assign, nonatomic, getter=isDisabled) BOOL disabled;
+@property (assign, nonatomic, getter=isHidden) BOOL hidden;
+@property (assign, nonatomic) id<GHTestDelegate> delegate; // weak
- (NSArray *)log;
- (void)reset;
- (void)cancel;
-- (void)setDisabled:(BOOL)disabled;
-- (BOOL)isDisabled;
- (NSInteger)disabledCount;
@end
@@ -119,12 +128,16 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
@interface GHTestOperation : NSOperation {
id<GHTest> test_;
+ GHTestOptions options_;
}
+
+- (id)initWithTest:(id<GHTest>)test options:(GHTestOptions)options;
+
@end
/*!
Default test implementation with a target/selector pair.
- - Consists of a target/selector
+ - Tests a target and selector
- Notifies a test delegate
- Keeps track of status, running time and failures
- Stores any test specific logging
@@ -141,22 +154,23 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
GHTestStatus status_;
NSTimeInterval interval_;
BOOL disabled_;
+ BOOL hidden_;
NSException *exception_; // If failed
NSMutableArray *log_;
+
}
@property (readonly, nonatomic) id target;
@property (readonly, nonatomic) SEL selector;
-@property (readonly, nonatomic) NSString *identifier; // Unique identifier for test
-@property (readonly, nonatomic) NSString *name;
-@property (readonly, nonatomic) NSTimeInterval interval;
-@property (retain, nonatomic) NSException *exception;
-@property (readonly, nonatomic) GHTestStatus status;
-@property (assign, nonatomic, getter=isDisabled) BOOL disabled;
@property (readonly, nonatomic) NSArray *log;
-@property (assign, nonatomic) NSObject<GHTestDelegate> *delegate;
+/*!
+ Creat test with identifier, name.
+ @param identifier Unique identifier
+ @param name Name
+ */
+- (id)initWithIdentifier:(NSString *)identifier name:(NSString *)name;
/*!
Create test with target/selector.
@@ -84,14 +84,16 @@
NSObject<GHTestDelegate> *delegate_; // weak
id<GHTestGroup> parent_; // weak
- NSMutableArray *children_; // of id<GHTest>
+ NSMutableArray */*of id<GHTest>*/children_;
NSString *name_; // The name of the test group (usually the class name of the test case
NSTimeInterval interval_; // Total time of child tests
GHTestStatus status_; // Current status of the group (current status of running or completed child tests)
GHTestStats stats_; // Current stats for the group (aggregate of child test stats)
BOOL didSetUpClass_;
+
+ GHTestOptions options_;
// Set if test is created from initWithTestCase:delegate:
// Allows use to perform setUpClass and tearDownClass (once per test case run)
@@ -101,17 +103,9 @@
}
@property (readonly, nonatomic) NSArray */*of id<GHTest>*/children;
-@property (assign, nonatomic) NSObject<GHTestDelegate> *delegate;
@property (assign, nonatomic) id<GHTestGroup> parent;
@property (readonly, nonatomic) id testCase;
-
-@property (readonly, nonatomic) NSString *identifier;
-@property (readonly, nonatomic) NSString *name;
-@property (readonly, nonatomic) GHTestStatus status;
-
-@property (readonly, nonatomic) NSTimeInterval interval;
-@property (readonly, nonatomic) GHTestStats stats;
-@property (readonly, nonatomic) NSException *exception;
+@property (assign, nonatomic) GHTestOptions options;
/*!
Create an empty test group.
@@ -155,13 +149,24 @@
- (void)addTestGroup:(GHTestGroup *)testGroup;
+- (void)addTests:(NSArray */*of id<GHTest>*/)tests;
+
+- (void)addTest:(id<GHTest>)test;
+
- (BOOL)shouldRunOnMainThread;
+/*!
+ Get list of failed tests.
+ @result Failed tests
+ */
+- (NSArray */*of id<GHTest>*/)failedTests;
+
/*!
Run in operation queue.
Tests from the group are added and will block until they have completed.
@param operationQueue If nil, then runs as is
+ @param options Options
*/
-- (void)runInOperationQueue:(NSOperationQueue *)operationQueue;
+- (void)runInOperationQueue:(NSOperationQueue *)operationQueue options:(GHTestOptions)options;
@end
@@ -86,6 +86,9 @@ extern NSString *const GHTestFilenameKey;
extern NSString *const GHTestLineNumberKey;
extern NSString *const GHTestFailureException;
+#if defined(__cplusplus)
+extern "C"
+#endif
NSString *GHComposeString(NSString *, ...);
// Generates a failure when a1 != noErr
@@ -74,24 +74,27 @@
id<GHTest> test_; // The test to run; Could be a GHTestGroup (suite), GHTestGroup (test case), or GHTest (target/selector)
NSObject<GHTestRunnerDelegate> *delegate_; // weak
-
- // If YES, will allow exceptions to be raised (so you can trigger the debugger)
- BOOL raiseExceptions_;
+
+ GHTestOptions options_;
BOOL running_;
BOOL cancelling_;
-
+
+ NSTimeInterval startInterval_;
+
NSOperationQueue *operationQueue_; //! If running a suite in operation queue
}
@property (retain) id<GHTest> test;
@property (assign) NSObject<GHTestRunnerDelegate> *delegate;
-@property (assign) BOOL raiseExceptions;
+@property (assign) GHTestOptions options;
@property (readonly) GHTestStats stats;
@property (readonly, getter=isRunning) BOOL running;
@property (readonly, getter=isCancelling) BOOL cancelling;
+@property (readonly) NSTimeInterval interval;
@property (retain, nonatomic) NSOperationQueue *operationQueue;
+
/*!
Create runner for test.
@param test
@@ -136,13 +139,16 @@
- (void)runInBackground;
/*!
- Start the test runner.
+ Start the test runner with the default test.
@result 0 is success, otherwise the failure count
*/
- (int)runTests;
- (void)cancel;
+- (void)setInParallel:(BOOL)inParallel;
+- (BOOL)isInParallel;
+
/*!
Write message to console.
*/
@@ -96,11 +96,42 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass);
*/
- (void)registerClassName:(NSString *)className;
+/*!
+ Format test exception.
+ @param exception
+ @result Description
+ */
++ (NSString *)descriptionForException:(NSException *)exception;
+
+/*!
+ Filename for cause of test exception.
+ @param test
+ @result Filename
+ */
++ (NSString *)exceptionFilenameForTest:(id<GHTest>)test;
+
+/*!
+ Line number for cause of test exception.
+ @param test
+ @result Line number
+ */
++ (NSInteger)exceptionLineNumberForTest:(id<GHTest>)test;
+
/*!
Run test.
- Exception if set is retained and should be released by the caller.
+ @param target
+ @param selector
+ @param exception Exception, if set, is retained and should be released by the caller.
+ @param interval Time to run the test
+ @param reraiseExceptions If YES, will re-raise exceptions
+ */
++ (BOOL)runTestWithTarget:(id)target selector:(SEL)selector exception:(NSException **)exception
+ interval:(NSTimeInterval *)interval reraiseExceptions:(BOOL)reraiseExceptions;
+
+/*!
+ Same as normal runTest without catching exceptions.
*/
-+ (BOOL)runTest:(id)target selector:(SEL)selector withObject:(id)obj exception:(NSException **)exception interval:(NSTimeInterval *)interval;
++ (BOOL)runTestOrRaiseWithTarget:(id)target selector:(SEL)selector exception:(NSException **)exception interval:(NSTimeInterval *)interval;
@end
@@ -0,0 +1,15 @@
+
+TEST_TARGET=Tests
+SDK=iphonesimulator3.0
+COMMAND=xcodebuild
+
+default:
+ # Set default make action here
+
+# If you need to clean a specific target/configuration: $(COMMAND) -target $(TARGET) -configuration DebugOrRelease -sdk $(SDK) clean
+clean:
+ -rm -rf build/*
+
+test:
+ GHUNIT_CLI=1 $(COMMAND) -target $(TEST_TARGET) -configuration Debug -sdk $(SDK) build
+
@@ -45,6 +45,11 @@
// the License.
//
+extern NSString *const GHTestFilenameKey;
+extern NSString *const GHTestLineNumberKey;
+extern NSString *const GHTestFailureException;
+
+
// GTM_BEGIN
#import <Foundation/Foundation.h>
Binary file not shown.
@@ -39,13 +39,26 @@ typedef enum {
GHTestStatusErrored, // Test finished and errored
} GHTestStatus;
+enum {
+ GHTestOptionReraiseExceptions = 1 << 0, // Allows exceptions to be raised (so you can trigger the debugger)
+ GHTestOptionForceSetUpTearDownClass = 1 << 1, // Runs setUpClass/tearDownClass for this (each) test; Used when re-running a single test in a group
+};
+typedef NSInteger GHTestOptions;
+
/*!
Generate string from GHTestStatus
@param status
*/
extern NSString* NSStringFromGHTestStatus(GHTestStatus status);
+/*!
+ Check if test is running (or trying to cancel).
+ */
extern BOOL GHTestStatusIsRunning(GHTestStatus status);
+
+/*!
+ Check if test has succeeded, errored or cancelled.
+ */
extern BOOL GHTestStatusEnded(GHTestStatus status);
/*!
@@ -73,9 +86,9 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
The base interface for a runnable test.
A runnable with a unique identifier, display name, stats, timer, delegate, log and error handling.
*/
-@protocol GHTest <NSObject, NSCoding>
+@protocol GHTest <NSObject, NSCoding, NSCopying>
-- (void)run;
+- (void)run:(GHTestOptions)options;
@property (readonly, nonatomic) NSString *identifier; // Unique identifier for test
@property (readonly, nonatomic) NSString *name;
@@ -115,7 +128,11 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
@interface GHTestOperation : NSOperation {
id<GHTest> test_;
+ GHTestOptions options_;
}
+
+- (id)initWithTest:(id<GHTest>)test options:(GHTestOptions)options;
+
@end
/*!
@@ -141,6 +158,7 @@ extern NSString *NSStringFromGHTestStats(GHTestStats stats);
NSException *exception_; // If failed
NSMutableArray *log_;
+
}
@property (readonly, nonatomic) id target;
@@ -8,8 +8,6 @@
#import "GHTestWindowController.h"
-#import "GHTestRunner.h"
-
@interface GHTestApp : NSObject {
NSMutableArray *topLevelObjects_;
Oops, something went wrong.

0 comments on commit e0280b5

Please sign in to comment.