Showing
40 changed files
with
562 additions
and
40 deletions
@@ -28,19 +28,40 @@ | @@ -28,19 +28,40 @@ | ||
28 | // | 28 | // |
29 | 29 | ||
30 | #import <Foundation/Foundation.h> | 30 | #import <Foundation/Foundation.h> |
31 | -#import <Foundation/NSDebug.h> | ||
32 | 31 | ||
33 | #import <GHUnit/GHUnit.h> | 32 | #import <GHUnit/GHUnit.h> |
34 | #import <GHUnit/GHTestApp.h> | 33 | #import <GHUnit/GHTestApp.h> |
35 | #import <GHUnit/GHTesting.h> | 34 | #import <GHUnit/GHTesting.h> |
36 | 35 | ||
36 | +// Default exception handler | ||
37 | +void exceptionHandler(NSException *exception) { | ||
38 | + NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception)); | ||
39 | +} | ||
40 | + | ||
37 | int main(int argc, char *argv[]) { | 41 | int main(int argc, char *argv[]) { |
38 | - // Setup any NSDebug settings | 42 | + |
39 | - NSDebugEnabled = YES; | 43 | + /*! |
40 | - NSZombieEnabled = YES; | 44 | + For debugging: |
41 | - NSDeallocateZombies = NO; | 45 | + Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode). |
42 | - NSHangOnUncaughtException = YES; | 46 | + Then go in the "Arguments" tab. You can add the following environment variables: |
43 | - setenv("NSAutoreleaseFreedObjectCheckEnabled", "1", 1); | 47 | + |
48 | + Default: Set to: | ||
49 | + NSDebugEnabled NO "YES" | ||
50 | + NSZombieEnabled NO "YES" | ||
51 | + NSDeallocateZombies NO "YES" | ||
52 | + NSHangOnUncaughtException NO "YES" | ||
53 | + | ||
54 | + NSEnableAutoreleasePool YES "NO" | ||
55 | + NSAutoreleaseFreedObjectCheckEnabled NO "YES" | ||
56 | + NSAutoreleaseHighWaterMark 0 non-negative integer | ||
57 | + NSAutoreleaseHighWaterResolution 0 non-negative integer | ||
58 | + | ||
59 | + For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html | ||
60 | + | ||
61 | + For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html | ||
62 | + */ | ||
63 | + | ||
64 | + NSSetUncaughtExceptionHandler(&exceptionHandler); | ||
44 | 65 | ||
45 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | 66 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
46 | 67 | ||
@@ -58,9 +79,11 @@ int main(int argc, char *argv[]) { | @@ -58,9 +79,11 @@ int main(int argc, char *argv[]) { | ||
58 | // To run a different test suite: | 79 | // To run a different test suite: |
59 | //GHTestSuite *suite = [GHTestSuite suiteWithTestFilter:@"GHSlowTest,GHAsyncTestCaseTest"]; | 80 | //GHTestSuite *suite = [GHTestSuite suiteWithTestFilter:@"GHSlowTest,GHAsyncTestCaseTest"]; |
60 | //GHTestApp *app = [[GHTestApp alloc] initWithSuite:suite]; | 81 | //GHTestApp *app = [[GHTestApp alloc] initWithSuite:suite]; |
82 | + // Or set global: | ||
83 | + //GHUnitTest = @"GHSlowTest"; | ||
61 | [NSApp run]; | 84 | [NSApp run]; |
62 | [app release]; | 85 | [app release]; |
63 | } | 86 | } |
64 | [pool release]; | 87 | [pool release]; |
65 | return retVal; | 88 | return retVal; |
66 | -} | 89 | +} |
No preview for this file type
@@ -8,8 +8,7 @@ | @@ -8,8 +8,7 @@ | ||
8 | 8 | ||
9 | #import <Cocoa/Cocoa.h> | 9 | #import <Cocoa/Cocoa.h> |
10 | 10 | ||
11 | -@interface BWSplitView : NSSplitView | 11 | +@interface BWSplitView : NSSplitView { |
12 | -{ | ||
13 | NSColor *color; | 12 | NSColor *color; |
14 | BOOL colorIsEnabled, checkboxIsEnabled, dividerCanCollapse, collapsibleSubviewCollapsed; | 13 | BOOL colorIsEnabled, checkboxIsEnabled, dividerCanCollapse, collapsibleSubviewCollapsed; |
15 | id secondaryDelegate; | 14 | id secondaryDelegate; |
@@ -63,7 +63,7 @@ typedef struct { | @@ -63,7 +63,7 @@ typedef struct { | ||
63 | */ | 63 | */ |
64 | extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount); | 64 | extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount); |
65 | 65 | ||
66 | -const GHTestStats GHTestStatsEmpty; | 66 | +extern const GHTestStats GHTestStatsEmpty; |
67 | 67 | ||
68 | extern NSString *NSStringFromGHTestStats(GHTestStats stats); | 68 | extern NSString *NSStringFromGHTestStats(GHTestStats stats); |
69 | 69 |
@@ -83,7 +83,7 @@ | @@ -83,7 +83,7 @@ | ||
83 | - (void)testB { } | 83 | - (void)testB { } |
84 | 84 | ||
85 | // Override any exceptions; By default exceptions are raised, causing a test failure | 85 | // Override any exceptions; By default exceptions are raised, causing a test failure |
86 | - - (void)failWithException:(NSException*)exception { } | 86 | + - (void)failWithException:(NSException *)exception { } |
87 | 87 | ||
88 | @end | 88 | @end |
89 | @endcode | 89 | @endcode |
This diff is collapsed. Click to expand it.
@@ -7,9 +7,9 @@ | @@ -7,9 +7,9 @@ | ||
7 | // | 7 | // |
8 | 8 | ||
9 | #import "GHTestViewModel.h" | 9 | #import "GHTestViewModel.h" |
10 | - | ||
11 | @class GHTestOutlineViewModel; | 10 | @class GHTestOutlineViewModel; |
12 | 11 | ||
12 | + | ||
13 | @protocol GHTestOutlineViewModelDelegate <NSObject> | 13 | @protocol GHTestOutlineViewModelDelegate <NSObject> |
14 | - (void)testOutlineViewModelDidChangeSelection:(GHTestOutlineViewModel *)testOutlineViewModel; | 14 | - (void)testOutlineViewModelDidChangeSelection:(GHTestOutlineViewModel *)testOutlineViewModel; |
15 | @end | 15 | @end |
@@ -85,6 +85,13 @@ extern NSString *GHUnitTest; | @@ -85,6 +85,13 @@ extern NSString *GHUnitTest; | ||
85 | + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter; | 85 | + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter; |
86 | 86 | ||
87 | /*! | 87 | /*! |
88 | + Create suite of tests that start with prefix. | ||
89 | + @param prefix If test case class starts with the prefix; If nil or empty string, returns all tests | ||
90 | + @param options Compare options | ||
91 | + */ | ||
92 | ++ (GHTestSuite *)suiteWithPrefix:(NSString *)prefix options:(NSStringCompareOptions)options; | ||
93 | + | ||
94 | +/*! | ||
88 | Suite for a single test/method. | 95 | Suite for a single test/method. |
89 | @param testCaseClass | 96 | @param testCaseClass |
90 | @param method | 97 | @param method |
@@ -110,30 +110,33 @@ | @@ -110,30 +110,33 @@ | ||
110 | NSMutableArray */* of GHTestNode*/children_; | 110 | NSMutableArray */* of GHTestNode*/children_; |
111 | 111 | ||
112 | id<GHTestNodeDelegate> delegate_; | 112 | id<GHTestNodeDelegate> delegate_; |
113 | -} | ||
114 | 113 | ||
114 | +} | ||
115 | 115 | ||
116 | 116 | ||
117 | -@property (readonly, nonatomic) NSString *identifier; | ||
118 | -@property (readonly, nonatomic) NSString *name; | ||
119 | @property (readonly, nonatomic) NSArray */* of GHTestNode*/children; | 117 | @property (readonly, nonatomic) NSArray */* of GHTestNode*/children; |
120 | @property (readonly, nonatomic) id<GHTest> test; | 118 | @property (readonly, nonatomic) id<GHTest> test; |
121 | -@property (readonly, nonatomic) GHTestStatus status; | ||
122 | -@property (readonly, nonatomic) NSString *statusString; | ||
123 | -@property (readonly, nonatomic) NSString *stackTrace; | ||
124 | -@property (readonly, nonatomic) NSString *log; | ||
125 | -@property (readonly, nonatomic) BOOL isRunning; | ||
126 | -@property (readonly, nonatomic) BOOL isEnded; | ||
127 | -@property (readonly, nonatomic) BOOL isGroupTest; // YES if test has "sub tests" | ||
128 | - | ||
129 | -@property (assign, nonatomic, getter=isSelected) BOOL selected; | ||
130 | @property (assign, nonatomic) id<GHTestNodeDelegate> delegate; | 119 | @property (assign, nonatomic) id<GHTestNodeDelegate> delegate; |
131 | 120 | ||
132 | - (id)initWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source; | 121 | - (id)initWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source; |
133 | + (GHTestNode *)nodeWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source; | 122 | + (GHTestNode *)nodeWithTest:(id<GHTest>)test children:(NSArray */*of GHTestNode */)children source:(GHTestViewModel *)source; |
134 | 123 | ||
124 | +- (NSString *)identifier; | ||
125 | +- (NSString *)name; | ||
135 | - (NSString *)nameWithStatus; | 126 | - (NSString *)nameWithStatus; |
136 | 127 | ||
128 | +- (GHTestStatus)status; | ||
129 | +- (NSString *)statusString; | ||
130 | +- (NSString *)stackTrace; | ||
131 | +- (NSString *)log; | ||
132 | +- (BOOL)isRunning; | ||
133 | +- (BOOL)isDisabled; | ||
134 | +- (BOOL)isEnded; | ||
135 | +- (BOOL)isGroupTest; // YES if test has "sub tests" | ||
136 | + | ||
137 | +- (BOOL)isSelected; | ||
138 | +- (void)setSelected:(BOOL)selected; | ||
139 | + | ||
137 | - (BOOL)hasChildren; | 140 | - (BOOL)hasChildren; |
138 | - (BOOL)failed; | 141 | - (BOOL)failed; |
139 | 142 |
@@ -46,6 +46,8 @@ | @@ -46,6 +46,8 @@ | ||
46 | // the License. | 46 | // the License. |
47 | // | 47 | // |
48 | 48 | ||
49 | +extern NSString *GHUStackTraceFromException(NSException *e); | ||
50 | + | ||
49 | // GTM_BEGIN | 51 | // GTM_BEGIN |
50 | BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); | 52 | BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); |
51 | // GTM_END | 53 | // GTM_END |
@@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); | @@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); | ||
102 | 104 | ||
103 | @end | 105 | @end |
104 | 106 | ||
107 | +@protocol GHSenTestCase | ||
108 | +- (void)raiseAfterFailure; | ||
109 | +@end |
@@ -34,7 +34,9 @@ | @@ -34,7 +34,9 @@ | ||
34 | #import "GHTestRunner.h" | 34 | #import "GHTestRunner.h" |
35 | 35 | ||
36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
37 | -#define GHUDebug(fmt, ...) NSLog(fmt, ##__VA_ARGS__) | 37 | +#define GHUDebug(fmt, ...) do { \ |
38 | +fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@"\n"] UTF8String], stdout); \ | ||
39 | +} while(0) | ||
38 | #else | 40 | #else |
39 | #define GHUDebug(fmt, ...) do {} while(0) | 41 | #define GHUDebug(fmt, ...) do {} while(0) |
40 | #endif | 42 | #endif |
1 | +// | ||
2 | +// GTMStackTrace.h | ||
3 | +// | ||
4 | +// Copyright 2007-2008 Google Inc. | ||
5 | +// | ||
6 | +// Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
7 | +// use this file except in compliance with the License. You may obtain a copy | ||
8 | +// of the License at | ||
9 | +// | ||
10 | +// http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | +// | ||
12 | +// Unless required by applicable law or agreed to in writing, software | ||
13 | +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
14 | +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
15 | +// License for the specific language governing permissions and limitations under | ||
16 | +// the License. | ||
17 | +// | ||
18 | + | ||
19 | +#include <CoreFoundation/CoreFoundation.h> | ||
20 | +#import "GTMDefines.h" | ||
21 | + | ||
22 | +#ifdef __cplusplus | ||
23 | +extern "C" { | ||
24 | +#endif | ||
25 | + | ||
26 | +struct GHU_GTMAddressDescriptor { | ||
27 | + const void *address; // address | ||
28 | + const char *symbol; // nearest symbol to address | ||
29 | + const char *class_name; // if it is an obj-c method, the method's class | ||
30 | + BOOL is_class_method; // if it is an obj-c method, type of method | ||
31 | + const char *filename; // file that the method came from. | ||
32 | +}; | ||
33 | + | ||
34 | +// Returns a string containing a nicely formatted stack trace. | ||
35 | +// | ||
36 | +// This function gets the stack trace for the current thread. It will | ||
37 | +// be from the caller of GTMStackTrace upwards to the top the calling stack. | ||
38 | +// Typically this function will be used along with some logging, | ||
39 | +// as in the following: | ||
40 | +// | ||
41 | +// MyAppLogger(@"Should never get here:\n%@", GTMStackTrace()); | ||
42 | +// | ||
43 | +// Here is a sample stack trace returned from this function: | ||
44 | +// | ||
45 | +// #0 0x00002d92 D () [/Users/me/./StackLog] | ||
46 | +// #1 0x00002e45 C () [/Users/me/./StackLog] | ||
47 | +// #2 0x00002e53 B () [/Users/me/./StackLog] | ||
48 | +// #3 0x00002e61 A () [/Users/me/./StackLog] | ||
49 | +// #4 0x00002e6f main () [/Users/me/./StackLog] | ||
50 | +// #5 0x00002692 tart () [/Users/me/./StackLog] | ||
51 | +// #6 0x000025b9 tart () [/Users/me/./StackLog] | ||
52 | +// | ||
53 | + | ||
54 | +NSString *GHU_GTMStackTrace(void); | ||
55 | + | ||
56 | +#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_5 | ||
57 | +// Returns a string containing a nicely formatted stack trace from the | ||
58 | +// exception. Only available on 10.5 or later, uses | ||
59 | +// -[NSException callStackReturnAddresses]. | ||
60 | +// | ||
61 | +NSString *GHU_GTMStackTraceFromException(NSException *e); | ||
62 | +#endif | ||
63 | + | ||
64 | +#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 | ||
65 | +// Returns an array of program counters from the current thread's stack. | ||
66 | +// *** You should probably use GTMStackTrace() instead of this function *** | ||
67 | +// However, if you actually want all the PCs in "void *" form, then this | ||
68 | +// funtion is more convenient. This will include PCs of GTMStaceTrace and | ||
69 | +// its inner utility functions that you may want to strip out. | ||
70 | +// | ||
71 | +// You can use +[NSThread callStackReturnAddresses] in 10.5 or later. | ||
72 | +// | ||
73 | +// Args: | ||
74 | +// outPcs - an array of "void *" pointers to the program counters found on the | ||
75 | +// current thread's stack. | ||
76 | +// count - the number of entries in the outPcs array | ||
77 | +// | ||
78 | +// Returns: | ||
79 | +// The number of program counters actually added to outPcs. | ||
80 | +// | ||
81 | +NSUInteger GHU_GTMGetStackProgramCounters(void *outPcs[], NSUInteger count); | ||
82 | +#endif // MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 | ||
83 | + | ||
84 | +// Returns an array of GTMAddressDescriptors from the current thread's stack. | ||
85 | +// *** You should probably use GTMStackTrace() instead of this function *** | ||
86 | +// However, if you actually want all the PCs with symbols, this is the way | ||
87 | +// to get them. There is no memory allocations done, so no clean up is required | ||
88 | +// except for the caller to free outDescs if they allocated it themselves. | ||
89 | +// This will include PCs of GTMStaceTrace and its inner utility functions that | ||
90 | +// you may want to strip out. | ||
91 | +// | ||
92 | +// Args: | ||
93 | +// outDescs - an array of "struct GTMAddressDescriptor" pointers corresponding | ||
94 | +// to the program counters found on the current thread's stack. | ||
95 | +// count - the number of entries in the outDescs array | ||
96 | +// | ||
97 | +// Returns: | ||
98 | +// The number of program counters actually added to outPcs. | ||
99 | +// | ||
100 | +NSUInteger GHU_GTMGetStackAddressDescriptors(struct GHU_GTMAddressDescriptor outDescs[], | ||
101 | + NSUInteger count); | ||
102 | + | ||
103 | +#ifdef __cplusplus | ||
104 | +} | ||
105 | +#endif |
1 | +// | ||
2 | +// NSException+GHTestFailureExceptions.h | ||
3 | +// | ||
4 | +// Created by Johannes Rudolph on 23.09.09. | ||
5 | +// Copyright 2009. All rights reserved. | ||
6 | +// | ||
7 | +// Permission is hereby granted, free of charge, to any person | ||
8 | +// obtaining a copy of this software and associated documentation | ||
9 | +// files (the "Software"), to deal in the Software without | ||
10 | +// restriction, including without limitation the rights to use, | ||
11 | +// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
12 | +// copies of the Software, and to permit persons to whom the | ||
13 | +// Software is furnished to do so, subject to the following | ||
14 | +// conditions: | ||
15 | +// | ||
16 | +// The above copyright notice and this permission notice shall be | ||
17 | +// included in all copies or substantial portions of the Software. | ||
18 | +// | ||
19 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
20 | +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
21 | +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
22 | +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
23 | +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
24 | +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
25 | +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
26 | +// OTHER DEALINGS IN THE SOFTWARE. | ||
27 | +// | ||
28 | + | ||
29 | +// | ||
30 | +// Portions of this file fall under the following license, marked with: | ||
31 | +// GTM_BEGIN : GTM_END | ||
32 | +// | ||
33 | +// Copyright 2008 Google Inc. | ||
34 | +// | ||
35 | +// Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
36 | +// use this file except in compliance with the License. You may obtain a copy | ||
37 | +// of the License at | ||
38 | +// | ||
39 | +// http://www.apache.org/licenses/LICENSE-2.0 | ||
40 | +// | ||
41 | +// Unless required by applicable law or agreed to in writing, software | ||
42 | +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
43 | +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
44 | +// License for the specific language governing permissions and limitations under | ||
45 | +// the License. | ||
46 | +// | ||
47 | + | ||
48 | +// GTM_BEGIN | ||
49 | + | ||
50 | +#import <Foundation/Foundation.h> | ||
51 | + | ||
52 | +@interface NSException (GHUTestFailureExceptions) | ||
53 | ++ (NSException *)ghu_failureInFile:(NSString *)filename | ||
54 | + atLine:(int)lineNumber | ||
55 | + withDescription:(NSString *)formatString, ...; | ||
56 | ++ (NSException *)ghu_failureInCondition:(NSString *)condition | ||
57 | + isTrue:(BOOL)isTrue | ||
58 | + inFile:(NSString *)filename | ||
59 | + atLine:(int)lineNumber | ||
60 | + withDescription:(NSString *)formatString, ...; | ||
61 | ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left | ||
62 | + andObject:(id)right | ||
63 | + inFile:(NSString *)filename | ||
64 | + atLine:(int)lineNumber | ||
65 | + withDescription:(NSString *)formatString, ...; | ||
66 | ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left | ||
67 | + andValue:(NSValue *)right | ||
68 | + withAccuracy:(NSValue *)accuracy | ||
69 | + inFile:(NSString *)filename | ||
70 | + atLine:(int) ineNumber | ||
71 | + withDescription:(NSString *)formatString, ...; | ||
72 | ++ (NSException *)ghu_failureInRaise:(NSString *)expression | ||
73 | + inFile:(NSString *)filename | ||
74 | + atLine:(int)lineNumber | ||
75 | + withDescription:(NSString *)formatString, ...; | ||
76 | ++ (NSException *)ghu_failureInRaise:(NSString *)expression | ||
77 | + exception:(NSException *)exception | ||
78 | + inFile:(NSString *)filename | ||
79 | + atLine:(int)lineNumber | ||
80 | + withDescription:(NSString *)formatString, ...; | ||
81 | +@end | ||
82 | + | ||
83 | +// GTM_END |
1 | +// | ||
2 | +// NSValue+GHValueFormatter.h | ||
3 | +// | ||
4 | +// Created by Johannes Rudolph on 23.9.2009. | ||
5 | +// Copyright 2009. All rights reserved. | ||
6 | +// | ||
7 | +// Permission is hereby granted, free of charge, to any person | ||
8 | +// obtaining a copy of this software and associated documentation | ||
9 | +// files (the "Software"), to deal in the Software without | ||
10 | +// restriction, including without limitation the rights to use, | ||
11 | +// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
12 | +// copies of the Software, and to permit persons to whom the | ||
13 | +// Software is furnished to do so, subject to the following | ||
14 | +// conditions: | ||
15 | +// | ||
16 | +// The above copyright notice and this permission notice shall be | ||
17 | +// included in all copies or substantial portions of the Software. | ||
18 | +// | ||
19 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
20 | +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
21 | +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
22 | +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
23 | +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
24 | +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
25 | +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
26 | +// OTHER DEALINGS IN THE SOFTWARE. | ||
27 | +// | ||
28 | + | ||
29 | +// | ||
30 | +// Portions of this file fall under the following license, marked with | ||
31 | +// SENTE_BEGIN - SENTE_END | ||
32 | +// | ||
33 | +// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved. | ||
34 | +// | ||
35 | +// Use of this source code is governed by the following license: | ||
36 | +// | ||
37 | +// Redistribution and use in source and binary forms, with or without modification, | ||
38 | +// are permitted provided that the following conditions are met: | ||
39 | +// | ||
40 | +// (1) Redistributions of source code must retain the above copyright notice, | ||
41 | +// this list of conditions and the following disclaimer. | ||
42 | +// | ||
43 | +// (2) Redistributions in binary form must reproduce the above copyright notice, | ||
44 | +// this list of conditions and the following disclaimer in the documentation | ||
45 | +// and/or other materials provided with the distribution. | ||
46 | +// | ||
47 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' | ||
48 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
49 | +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
50 | +// IN NO EVENT SHALL Sente SA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
51 | +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
52 | +// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
53 | +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
54 | +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
55 | +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
56 | +// | ||
57 | +// Note: this license is equivalent to the FreeBSD license. | ||
58 | +// | ||
59 | +// This notice may not be removed from this file. | ||
60 | + | ||
61 | +#import <Foundation/Foundation.h> | ||
62 | + | ||
63 | +// SENTE_BEGIN | ||
64 | +@interface NSValue (GHValueFormatter) | ||
65 | +- (NSString *)ghu_contentDescription; | ||
66 | +@end | ||
67 | +// SENTE_END |
No preview for this file type
No preview for this file type
No preview for this file type
@@ -17,6 +17,6 @@ | @@ -17,6 +17,6 @@ | ||
17 | <key>CFBundleSignature</key> | 17 | <key>CFBundleSignature</key> |
18 | <string>GABE</string> | 18 | <string>GABE</string> |
19 | <key>CFBundleVersion</key> | 19 | <key>CFBundleVersion</key> |
20 | - <string>0.4.4</string> | 20 | + <string>0.4.14</string> |
21 | </dict> | 21 | </dict> |
22 | </plist> | 22 | </plist> |
File moved
@@ -63,7 +63,7 @@ typedef struct { | @@ -63,7 +63,7 @@ typedef struct { | ||
63 | */ | 63 | */ |
64 | extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount); | 64 | extern GHTestStats GHTestStatsMake(NSInteger succeedCount, NSInteger failureCount, NSInteger cancelCount, NSInteger testCount); |
65 | 65 | ||
66 | -const GHTestStats GHTestStatsEmpty; | 66 | +extern const GHTestStats GHTestStatsEmpty; |
67 | 67 | ||
68 | extern NSString *NSStringFromGHTestStats(GHTestStats stats); | 68 | extern NSString *NSStringFromGHTestStats(GHTestStats stats); |
69 | 69 |
@@ -83,7 +83,7 @@ | @@ -83,7 +83,7 @@ | ||
83 | - (void)testB { } | 83 | - (void)testB { } |
84 | 84 | ||
85 | // Override any exceptions; By default exceptions are raised, causing a test failure | 85 | // Override any exceptions; By default exceptions are raised, causing a test failure |
86 | - - (void)failWithException:(NSException*)exception { } | 86 | + - (void)failWithException:(NSException *)exception { } |
87 | 87 | ||
88 | @end | 88 | @end |
89 | @endcode | 89 | @endcode |
This diff is collapsed. Click to expand it.
@@ -85,6 +85,13 @@ extern NSString *GHUnitTest; | @@ -85,6 +85,13 @@ extern NSString *GHUnitTest; | ||
85 | + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter; | 85 | + (GHTestSuite *)suiteWithTestFilter:(NSString *)testFilter; |
86 | 86 | ||
87 | /*! | 87 | /*! |
88 | + Create suite of tests that start with prefix. | ||
89 | + @param prefix If test case class starts with the prefix; If nil or empty string, returns all tests | ||
90 | + @param options Compare options | ||
91 | + */ | ||
92 | ++ (GHTestSuite *)suiteWithPrefix:(NSString *)prefix options:(NSStringCompareOptions)options; | ||
93 | + | ||
94 | +/*! | ||
88 | Suite for a single test/method. | 95 | Suite for a single test/method. |
89 | @param testCaseClass | 96 | @param testCaseClass |
90 | @param method | 97 | @param method |
@@ -46,6 +46,8 @@ | @@ -46,6 +46,8 @@ | ||
46 | // the License. | 46 | // the License. |
47 | // | 47 | // |
48 | 48 | ||
49 | +extern NSString *GHUStackTraceFromException(NSException *e); | ||
50 | + | ||
49 | // GTM_BEGIN | 51 | // GTM_BEGIN |
50 | BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); | 52 | BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); |
51 | // GTM_END | 53 | // GTM_END |
@@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); | @@ -102,3 +104,6 @@ BOOL isTestFixtureOfClass(Class aClass, Class testCaseClass); | ||
102 | 104 | ||
103 | @end | 105 | @end |
104 | 106 | ||
107 | +@protocol GHSenTestCase | ||
108 | +- (void)raiseAfterFailure; | ||
109 | +@end |
@@ -34,7 +34,9 @@ | @@ -34,7 +34,9 @@ | ||
34 | #import "GHTestRunner.h" | 34 | #import "GHTestRunner.h" |
35 | 35 | ||
36 | #ifdef DEBUG | 36 | #ifdef DEBUG |
37 | -#define GHUDebug(fmt, ...) NSLog(fmt, ##__VA_ARGS__) | 37 | +#define GHUDebug(fmt, ...) do { \ |
38 | +fputs([[[NSString stringWithFormat:fmt, ##__VA_ARGS__] stringByAppendingString:@"\n"] UTF8String], stdout); \ | ||
39 | +} while(0) | ||
38 | #else | 40 | #else |
39 | #define GHUDebug(fmt, ...) do {} while(0) | 41 | #define GHUDebug(fmt, ...) do {} while(0) |
40 | #endif | 42 | #endif |
1 | +// | ||
2 | +// GHUnitIPhoneAppDelegate.h | ||
3 | +// GHUnitIPhone | ||
4 | +// | ||
5 | +// Created by Gabriel Handford on 1/25/09. | ||
6 | +// Copyright 2009. All rights reserved. | ||
7 | +// | ||
8 | + | ||
9 | +#import <UIKit/UIKit.h> | ||
10 | + | ||
11 | +@interface GHUnitIPhoneAppDelegate : NSObject <UIApplicationDelegate> { | ||
12 | + UIWindow *window_; | ||
13 | + | ||
14 | + UINavigationController *navigationController_; | ||
15 | +} | ||
16 | + | ||
17 | +@end | ||
18 | + |
@@ -9,18 +9,37 @@ | @@ -9,18 +9,37 @@ | ||
9 | #import <UIKit/UIKit.h> | 9 | #import <UIKit/UIKit.h> |
10 | 10 | ||
11 | #import "GHUnit.h" | 11 | #import "GHUnit.h" |
12 | +#import "GHTesting.h" | ||
12 | 13 | ||
13 | -extern BOOL NSDebugEnabled; | 14 | +// Default exception handler |
14 | -extern BOOL NSZombieEnabled; | 15 | +void exceptionHandler(NSException *exception) { |
15 | -extern BOOL NSDeallocateZombies; | 16 | + NSLog(@"%@\n%@", [exception reason], GHUStackTraceFromException(exception)); |
16 | -extern BOOL NSHangOnUncaughtException; | 17 | +} |
17 | 18 | ||
18 | int main(int argc, char *argv[]) { | 19 | int main(int argc, char *argv[]) { |
19 | 20 | ||
20 | - NSDebugEnabled = YES; | 21 | + /*! |
21 | - NSZombieEnabled = YES; | 22 | + For debugging: |
22 | - NSDeallocateZombies = NO; | 23 | + Go into the "Get Info" contextual menu of your (test) executable (inside the "Executables" group in the left panel of XCode). |
23 | - NSHangOnUncaughtException = YES; | 24 | + Then go in the "Arguments" tab. You can add the following environment variables: |
25 | + | ||
26 | + Default: Set to: | ||
27 | + NSDebugEnabled NO "YES" | ||
28 | + NSZombieEnabled NO "YES" | ||
29 | + NSDeallocateZombies NO "YES" | ||
30 | + NSHangOnUncaughtException NO "YES" | ||
31 | + | ||
32 | + NSEnableAutoreleasePool YES "NO" | ||
33 | + NSAutoreleaseFreedObjectCheckEnabled NO "YES" | ||
34 | + NSAutoreleaseHighWaterMark 0 non-negative integer | ||
35 | + NSAutoreleaseHighWaterResolution 0 non-negative integer | ||
36 | + | ||
37 | + For info on these varaiables see NSDebug.h; http://theshadow.uw.hu/iPhoneSDKdoc/Foundation.framework/NSDebug.h.html | ||
38 | + | ||
39 | + For malloc debugging see: http://developer.apple.com/mac/library/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html | ||
40 | + */ | ||
41 | + | ||
42 | + NSSetUncaughtExceptionHandler(&exceptionHandler); | ||
24 | 43 | ||
25 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; | 44 | NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; |
26 | 45 |
Frameworks/libGHUnitIPhone3_0-0/Makefile
0 → 100644
1 | + | ||
2 | +TEST_TARGET=Tests | ||
3 | +SDK=iphonesimulator3.0 | ||
4 | +COMMAND=xcodebuild | ||
5 | + | ||
6 | +default: | ||
7 | + # Set default make action here | ||
8 | + | ||
9 | +# If you need to clean a specific target/configuration: $(COMMAND) -target $(TARGET) -configuration DebugOrRelease -sdk $(SDK) clean | ||
10 | +clean: | ||
11 | + -rm -rf build/* | ||
12 | + | ||
13 | +test: | ||
14 | + GHUNIT_CLI=1 $(COMMAND) -target $(TEST_TARGET) -configuration Debug -sdk $(SDK) build | ||
15 | + |
1 | +// | ||
2 | +// NSException+GHTestFailureExceptions.h | ||
3 | +// | ||
4 | +// Created by Johannes Rudolph on 23.09.09. | ||
5 | +// Copyright 2009. All rights reserved. | ||
6 | +// | ||
7 | +// Permission is hereby granted, free of charge, to any person | ||
8 | +// obtaining a copy of this software and associated documentation | ||
9 | +// files (the "Software"), to deal in the Software without | ||
10 | +// restriction, including without limitation the rights to use, | ||
11 | +// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
12 | +// copies of the Software, and to permit persons to whom the | ||
13 | +// Software is furnished to do so, subject to the following | ||
14 | +// conditions: | ||
15 | +// | ||
16 | +// The above copyright notice and this permission notice shall be | ||
17 | +// included in all copies or substantial portions of the Software. | ||
18 | +// | ||
19 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
20 | +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
21 | +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
22 | +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
23 | +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
24 | +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
25 | +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
26 | +// OTHER DEALINGS IN THE SOFTWARE. | ||
27 | +// | ||
28 | + | ||
29 | +// | ||
30 | +// Portions of this file fall under the following license, marked with: | ||
31 | +// GTM_BEGIN : GTM_END | ||
32 | +// | ||
33 | +// Copyright 2008 Google Inc. | ||
34 | +// | ||
35 | +// Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
36 | +// use this file except in compliance with the License. You may obtain a copy | ||
37 | +// of the License at | ||
38 | +// | ||
39 | +// http://www.apache.org/licenses/LICENSE-2.0 | ||
40 | +// | ||
41 | +// Unless required by applicable law or agreed to in writing, software | ||
42 | +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
43 | +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
44 | +// License for the specific language governing permissions and limitations under | ||
45 | +// the License. | ||
46 | +// | ||
47 | + | ||
48 | +// GTM_BEGIN | ||
49 | + | ||
50 | +#import <Foundation/Foundation.h> | ||
51 | + | ||
52 | +@interface NSException (GHUTestFailureExceptions) | ||
53 | ++ (NSException *)ghu_failureInFile:(NSString *)filename | ||
54 | + atLine:(int)lineNumber | ||
55 | + withDescription:(NSString *)formatString, ...; | ||
56 | ++ (NSException *)ghu_failureInCondition:(NSString *)condition | ||
57 | + isTrue:(BOOL)isTrue | ||
58 | + inFile:(NSString *)filename | ||
59 | + atLine:(int)lineNumber | ||
60 | + withDescription:(NSString *)formatString, ...; | ||
61 | ++ (NSException *)ghu_failureInEqualityBetweenObject:(id)left | ||
62 | + andObject:(id)right | ||
63 | + inFile:(NSString *)filename | ||
64 | + atLine:(int)lineNumber | ||
65 | + withDescription:(NSString *)formatString, ...; | ||
66 | ++ (NSException *)ghu_failureInEqualityBetweenValue:(NSValue *)left | ||
67 | + andValue:(NSValue *)right | ||
68 | + withAccuracy:(NSValue *)accuracy | ||
69 | + inFile:(NSString *)filename | ||
70 | + atLine:(int) ineNumber | ||
71 | + withDescription:(NSString *)formatString, ...; | ||
72 | ++ (NSException *)ghu_failureInRaise:(NSString *)expression | ||
73 | + inFile:(NSString *)filename | ||
74 | + atLine:(int)lineNumber | ||
75 | + withDescription:(NSString *)formatString, ...; | ||
76 | ++ (NSException *)ghu_failureInRaise:(NSString *)expression | ||
77 | + exception:(NSException *)exception | ||
78 | + inFile:(NSString *)filename | ||
79 | + atLine:(int)lineNumber | ||
80 | + withDescription:(NSString *)formatString, ...; | ||
81 | +@end | ||
82 | + | ||
83 | +// GTM_END |
1 | +// | ||
2 | +// NSValue+GHValueFormatter.h | ||
3 | +// | ||
4 | +// Created by Johannes Rudolph on 23.9.2009. | ||
5 | +// Copyright 2009. All rights reserved. | ||
6 | +// | ||
7 | +// Permission is hereby granted, free of charge, to any person | ||
8 | +// obtaining a copy of this software and associated documentation | ||
9 | +// files (the "Software"), to deal in the Software without | ||
10 | +// restriction, including without limitation the rights to use, | ||
11 | +// copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
12 | +// copies of the Software, and to permit persons to whom the | ||
13 | +// Software is furnished to do so, subject to the following | ||
14 | +// conditions: | ||
15 | +// | ||
16 | +// The above copyright notice and this permission notice shall be | ||
17 | +// included in all copies or substantial portions of the Software. | ||
18 | +// | ||
19 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
20 | +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
21 | +// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
22 | +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
23 | +// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
24 | +// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
25 | +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
26 | +// OTHER DEALINGS IN THE SOFTWARE. | ||
27 | +// | ||
28 | + | ||
29 | +// | ||
30 | +// Portions of this file fall under the following license, marked with | ||
31 | +// SENTE_BEGIN - SENTE_END | ||
32 | +// | ||
33 | +// Copyright (c) 1997-2005, Sen:te (Sente SA). All rights reserved. | ||
34 | +// | ||
35 | +// Use of this source code is governed by the following license: | ||
36 | +// | ||
37 | +// Redistribution and use in source and binary forms, with or without modification, | ||
38 | +// are permitted provided that the following conditions are met: | ||
39 | +// | ||
40 | +// (1) Redistributions of source code must retain the above copyright notice, | ||
41 | +// this list of conditions and the following disclaimer. | ||
42 | +// | ||
43 | +// (2) Redistributions in binary form must reproduce the above copyright notice, | ||
44 | +// this list of conditions and the following disclaimer in the documentation | ||
45 | +// and/or other materials provided with the distribution. | ||
46 | +// | ||
47 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' | ||
48 | +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
49 | +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
50 | +// IN NO EVENT SHALL Sente SA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
51 | +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT | ||
52 | +// OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
53 | +// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
54 | +// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | ||
55 | +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
56 | +// | ||
57 | +// Note: this license is equivalent to the FreeBSD license. | ||
58 | +// | ||
59 | +// This notice may not be removed from this file. | ||
60 | + | ||
61 | +#import <Foundation/Foundation.h> | ||
62 | + | ||
63 | +// SENTE_BEGIN | ||
64 | +@interface NSValue (GHValueFormatter) | ||
65 | +- (NSString *)ghu_contentDescription; | ||
66 | +@end | ||
67 | +// SENTE_END |
No preview for this file type
@@ -20,7 +20,5 @@ | @@ -20,7 +20,5 @@ | ||
20 | <string>????</string> | 20 | <string>????</string> |
21 | <key>CFBundleVersion</key> | 21 | <key>CFBundleVersion</key> |
22 | <string>1.0</string> | 22 | <string>1.0</string> |
23 | - <key>NSMainNibFile</key> | ||
24 | - <string>GHUnitIPhone</string> | ||
25 | </dict> | 23 | </dict> |
26 | </plist> | 24 | </plist> |
This diff was suppressed by a .gitattributes entry.
-
Please register or login to post a comment