diff options
-rw-r--r-- | GTM.xcodeproj/project.pbxproj | 4 | ||||
-rw-r--r-- | GTMiPhone.xcodeproj/project.pbxproj | 4 | ||||
-rw-r--r-- | UnitTesting/GTMSenTestCase.m | 92 | ||||
-rw-r--r-- | UnitTesting/GTMSenTestCaseTest.m | 72 | ||||
-rw-r--r-- | UnitTesting/GTMUnitTestingTest.m | 113 |
5 files changed, 185 insertions, 100 deletions
diff --git a/GTM.xcodeproj/project.pbxproj b/GTM.xcodeproj/project.pbxproj index 38afd17..88d4537 100644 --- a/GTM.xcodeproj/project.pbxproj +++ b/GTM.xcodeproj/project.pbxproj @@ -386,6 +386,7 @@ F43E4E610D4E5EC90041161F /* GTMNSData+zlib.h in Headers */ = {isa = PBXBuildFile; fileRef = F43E4E5E0D4E5EC90041161F /* GTMNSData+zlib.h */; settings = {ATTRIBUTES = (Public, ); }; }; F43E4E620D4E5EC90041161F /* GTMNSData+zlib.m in Sources */ = {isa = PBXBuildFile; fileRef = F43E4E5F0D4E5EC90041161F /* GTMNSData+zlib.m */; }; F43E4F6D0D4E60C50041161F /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = F43E4F6C0D4E60C50041161F /* libz.dylib */; }; + F47466661296F19E0022C1FB /* GTMSenTestCaseTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F47466651296F19E0022C1FB /* GTMSenTestCaseTest.m */; }; F47A79880D746EE9002302AB /* GTMScriptRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = F47A79850D746EE9002302AB /* GTMScriptRunner.h */; settings = {ATTRIBUTES = (Public, ); }; }; F47A79890D746EE9002302AB /* GTMScriptRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = F47A79860D746EE9002302AB /* GTMScriptRunner.m */; }; F47F1C120D490BC000925B8F /* GTMNSBezierPath+Shading.h in Headers */ = {isa = PBXBuildFile; fileRef = F47F1C0D0D490BC000925B8F /* GTMNSBezierPath+Shading.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -857,6 +858,7 @@ F43E4E600D4E5EC90041161F /* GTMNSData+zlibTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMNSData+zlibTest.m"; sourceTree = "<group>"; }; F43E4F6C0D4E60C50041161F /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = /usr/lib/libz.dylib; sourceTree = "<absolute>"; }; F440EDB70DFECC4B0003E81F /* BuildingAndUsing.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = BuildingAndUsing.txt; sourceTree = "<group>"; }; + F47466651296F19E0022C1FB /* GTMSenTestCaseTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMSenTestCaseTest.m; sourceTree = "<group>"; }; F47A79850D746EE9002302AB /* GTMScriptRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMScriptRunner.h; sourceTree = "<group>"; }; F47A79860D746EE9002302AB /* GTMScriptRunner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMScriptRunner.m; sourceTree = "<group>"; }; F47A79870D746EE9002302AB /* GTMScriptRunnerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMScriptRunnerTest.m; sourceTree = "<group>"; }; @@ -1562,6 +1564,7 @@ F48FE29C0D198D36009257D2 /* GTMNSObject+UnitTesting.m */, F48FE29F0D198D36009257D2 /* GTMSenTestCase.h */, 8B7DCE180DFF39850017E983 /* GTMSenTestCase.m */, + F47466651296F19E0022C1FB /* GTMSenTestCaseTest.m */, 8B3590150E8190FA0041E21C /* GTMTestTimer.h */, 8B35901A0E8191750041E21C /* GTMTestTimerTest.m */, 8B7DCBF00DFF1A610017E983 /* GTMUnitTestDevLog.h */, @@ -2203,6 +2206,7 @@ 8B7DCBEF0DFF1A4F0017E983 /* GTMUnitTestDevLog.m in Sources */, 8B7DCE1B0DFF39850017E983 /* GTMSenTestCase.m in Sources */, 8B35901B0E8191750041E21C /* GTMTestTimerTest.m in Sources */, + F47466661296F19E0022C1FB /* GTMSenTestCaseTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/GTMiPhone.xcodeproj/project.pbxproj b/GTMiPhone.xcodeproj/project.pbxproj index 7e2a5e0..306852b 100644 --- a/GTMiPhone.xcodeproj/project.pbxproj +++ b/GTMiPhone.xcodeproj/project.pbxproj @@ -121,6 +121,7 @@ F418AFD80E755D44004FB565 /* GTMPathTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F418AFD60E755D44004FB565 /* GTMPathTest.m */; }; F439ADF00DBD3C4000BE9B91 /* GTMGeometryUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = F439ADEE0DBD3C4000BE9B91 /* GTMGeometryUtils.m */; }; F439ADF10DBD3C4000BE9B91 /* GTMGeometryUtilsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F439ADEF0DBD3C4000BE9B91 /* GTMGeometryUtilsTest.m */; }; + F4746721129703600022C1FB /* GTMSenTestCaseTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4746720129703600022C1FB /* GTMSenTestCaseTest.m */; }; F4E3B3D80EB5EF2400CB713D /* GTMUIFont+LineHeight.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E3B3D70EB5EF2400CB713D /* GTMUIFont+LineHeight.m */; }; F4E3B3E20EB5EF9A00CB713D /* GTMUIFont+LineHeightTest.m in Sources */ = {isa = PBXBuildFile; fileRef = F4E3B3E10EB5EF9A00CB713D /* GTMUIFont+LineHeightTest.m */; }; F4EF8AD70EBFF814008DD6DA /* GTMStackTrace.m in Sources */ = {isa = PBXBuildFile; fileRef = F4EF8AD50EBFF814008DD6DA /* GTMStackTrace.m */; }; @@ -298,6 +299,7 @@ F439ADED0DBD3C4000BE9B91 /* GTMGeometryUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GTMGeometryUtils.h; sourceTree = "<group>"; }; F439ADEE0DBD3C4000BE9B91 /* GTMGeometryUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMGeometryUtils.m; sourceTree = "<group>"; }; F439ADEF0DBD3C4000BE9B91 /* GTMGeometryUtilsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMGeometryUtilsTest.m; sourceTree = "<group>"; }; + F4746720129703600022C1FB /* GTMSenTestCaseTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GTMSenTestCaseTest.m; sourceTree = "<group>"; }; F4E3B3D60EB5EF2400CB713D /* GTMUIFont+LineHeight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "GTMUIFont+LineHeight.h"; sourceTree = "<group>"; }; F4E3B3D70EB5EF2400CB713D /* GTMUIFont+LineHeight.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMUIFont+LineHeight.m"; sourceTree = "<group>"; }; F4E3B3E10EB5EF9A00CB713D /* GTMUIFont+LineHeightTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "GTMUIFont+LineHeightTest.m"; sourceTree = "<group>"; }; @@ -551,6 +553,7 @@ 8BC047ED0DAE928A00C2D1CA /* GTMNSObject+UnitTesting.m */, 8BC047F60DAE928A00C2D1CA /* GTMSenTestCase.h */, 8BC047F70DAE928A00C2D1CA /* GTMSenTestCase.m */, + F4746720129703600022C1FB /* GTMSenTestCaseTest.m */, 8BC048010DAE928A00C2D1CA /* GTMUIViewUnitTestingTest.png */, 8B7DCEAB0DFF4CA60017E983 /* GTMUnitTestDevLog.h */, 8B7DCEAC0DFF4CA60017E983 /* GTMUnitTestDevLog.m */, @@ -833,6 +836,7 @@ 8BFFCD7811C1934900E45777 /* GTMNSObject+KeyValueObservingTest.m in Sources */, 8B2908B211F8E7070064F50F /* GTMNSFileHandle+UniqueName.m in Sources */, 8B2908B311F8E7070064F50F /* GTMNSFileHandle+UniqueNameTest.m in Sources */, + F4746721129703600022C1FB /* GTMSenTestCaseTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/UnitTesting/GTMSenTestCase.m b/UnitTesting/GTMSenTestCase.m index 5c90ae9..2b0a8f7 100644 --- a/UnitTesting/GTMSenTestCase.m +++ b/UnitTesting/GTMSenTestCase.m @@ -329,53 +329,69 @@ NSString *const SenTestLineNumberKey = @"SenTestLineNumberKey"; } // Used for sorting methods below -static int MethodSort(const void *a, const void *b) { - const char *nameA = sel_getName(method_getName(*(Method*)a)); - const char *nameB = sel_getName(method_getName(*(Method*)b)); +static int MethodSort(id a, id b, void *context) { + NSInvocation *invocationA = a; + NSInvocation *invocationB = b; + const char *nameA = sel_getName([invocationA selector]); + const char *nameB = sel_getName([invocationB selector]); return strcmp(nameA, nameB); } + + (NSArray *)testInvocations { NSMutableArray *invocations = nil; - unsigned int methodCount; - Method *methods = class_copyMethodList(self, &methodCount); - if (methods) { - // This handles disposing of methods for us even if an exception should fly. - [NSData dataWithBytesNoCopy:methods - length:sizeof(Method) * methodCount]; - // Sort our methods so they are called in Alphabetical order just - // because we can. - qsort(methods, methodCount, sizeof(Method), MethodSort); - invocations = [NSMutableArray arrayWithCapacity:methodCount]; - for (size_t i = 0; i < methodCount; ++i) { - Method currMethod = methods[i]; - SEL sel = method_getName(currMethod); - char *returnType = NULL; - const char *name = sel_getName(sel); - // If it starts with test, takes 2 args (target and sel) and returns - // void run it. - if (strstr(name, "test") == name) { - returnType = method_copyReturnType(currMethod); - if (returnType) { - // This handles disposing of returnType for us even if an - // exception should fly. Length +1 for the terminator, not that - // the length really matters here, as we never reference inside - // the data block. - [NSData dataWithBytesNoCopy:returnType - length:strlen(returnType) + 1]; - } + // Need to walk all the way up the parent classes collecting methods (in case + // a test is a subclass of another test). + Class senTestCaseClass = [SenTestCase class]; + for (Class currentClass = self; + currentClass && (currentClass != senTestCaseClass); + currentClass = class_getSuperclass(currentClass)) { + unsigned int methodCount; + Method *methods = class_copyMethodList(currentClass, &methodCount); + if (methods) { + // This handles disposing of methods for us even if an exception should fly. + [NSData dataWithBytesNoCopy:methods + length:sizeof(Method) * methodCount]; + if (!invocations) { + invocations = [NSMutableArray arrayWithCapacity:methodCount]; } - if (returnType // True if name starts with "test" - && strcmp(returnType, @encode(void)) == 0 - && method_getNumberOfArguments(currMethod) == 2) { - NSMethodSignature *sig = [self instanceMethodSignatureForSelector:sel]; - NSInvocation *invocation - = [NSInvocation invocationWithMethodSignature:sig]; - [invocation setSelector:sel]; - [invocations addObject:invocation]; + for (size_t i = 0; i < methodCount; ++i) { + Method currMethod = methods[i]; + SEL sel = method_getName(currMethod); + char *returnType = NULL; + const char *name = sel_getName(sel); + // If it starts with test, takes 2 args (target and sel) and returns + // void run it. + if (strstr(name, "test") == name) { + returnType = method_copyReturnType(currMethod); + if (returnType) { + // This handles disposing of returnType for us even if an + // exception should fly. Length +1 for the terminator, not that + // the length really matters here, as we never reference inside + // the data block. + [NSData dataWithBytesNoCopy:returnType + length:strlen(returnType) + 1]; + } + } + // TODO: If a test class is a subclass of another, and they reuse the + // same selector name (ie-subclass overrides it), this current loop + // and test here will cause cause it to get invoked twice. To fix this + // the selector would have to be checked against all the ones already + // added, so it only gets done once. + if (returnType // True if name starts with "test" + && strcmp(returnType, @encode(void)) == 0 + && method_getNumberOfArguments(currMethod) == 2) { + NSMethodSignature *sig = [self instanceMethodSignatureForSelector:sel]; + NSInvocation *invocation + = [NSInvocation invocationWithMethodSignature:sig]; + [invocation setSelector:sel]; + [invocations addObject:invocation]; + } } } } + // Match SenTestKit and run everything in alphbetical order. + [invocations sortUsingFunction:MethodSort context:nil]; return invocations; } diff --git a/UnitTesting/GTMSenTestCaseTest.m b/UnitTesting/GTMSenTestCaseTest.m new file mode 100644 index 0000000..9d9a594 --- /dev/null +++ b/UnitTesting/GTMSenTestCaseTest.m @@ -0,0 +1,72 @@ +// +// GTMSenTestCaseTest.m +// +// Copyright 2010 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); you may not +// use this file except in compliance with the License. You may obtain a copy +// of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +// License for the specific language governing permissions and limitations under +// the License. +// + +#import "GTMSenTestCase.h" + +// These make use of the fact that methods are run in alphebetical order +// to have one test check that a previous one was run. If that order ever +// changes, there is a good chance things will break. + +static int gAbstractCalls_ = 0; +static int gZzCheckCalls_ = 0; + +@interface GTMTestingAbstractTest : GTMTestCase +@end + +@interface GTMTestingTestOne : GTMTestingAbstractTest { + BOOL zzCheckCalled_; +} +@end + +@interface GTMTestingTestTwo : GTMTestingTestOne +@end + +@implementation GTMTestingAbstractTest + +- (void)testAbstractUnitTest { + STAssertFalse([self isMemberOfClass:[GTMTestingAbstractTest class]], + @"test should not run on the abstract class"); + ++gAbstractCalls_; +} + +@end + +@implementation GTMTestingTestOne + +- (void)testZZCheck { + ++gZzCheckCalls_; + if ([self isMemberOfClass:[GTMTestingTestOne class]]) { + STAssertEquals(gAbstractCalls_, 1, + @"wrong number of abstract calls at this point"); + } else { + STAssertTrue([self isMemberOfClass:[GTMTestingTestTwo class]], nil); + STAssertEquals(gAbstractCalls_, 2, + @"wrong number of abstract calls at this point"); + } +} + +@end + +@implementation GTMTestingTestTwo + +- (void)testZZZCheck { + // Test defined at this leaf, it should always run, check on the other methods. + STAssertEquals(gZzCheckCalls_, 2, @"the parent class method wasn't called"); +} + +@end diff --git a/UnitTesting/GTMUnitTestingTest.m b/UnitTesting/GTMUnitTestingTest.m index 8ee2244..d14795f 100644 --- a/UnitTesting/GTMUnitTestingTest.m +++ b/UnitTesting/GTMUnitTestingTest.m @@ -6,9 +6,9 @@ // Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy // of the License at -// +// // http://www.apache.org/licenses/LICENSE-2.0 -// +// // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the @@ -16,17 +16,14 @@ // the License. // -#import <SenTestingKit/SenTestingKit.h> +#import "GTMSenTestCase.h" #import "GTMUnitTestingTest.h" #import "GTMAppKit+UnitTesting.h" NSString *const kGTMWindowNibName = @"GTMUnitTestingTest"; NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow"; -@interface GTMUnitTestingAbstractTest : GTMTestCase -@end - -@interface GTMUnitTestingTest : GTMUnitTestingAbstractTest { +@interface GTMUnitTestingTest : GTMTestCase { int expectedFailureCount_; } @end @@ -47,17 +44,9 @@ NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow"; @interface GTMUnitTestingProxyTest : NSProxy @end -@implementation GTMUnitTestingAbstractTest -- (void)testAbstractUnitTest { - static int testCount = 0; - testCount += 1; - STAssertEquals(testCount, 1, @"testAbstractUnitTest should only fire once"); -} -@end - @implementation GTMUnitTestingTest - -// Brings up the window defined in the nib and takes a snapshot of it. + +// Brings up the window defined in the nib and takes a snapshot of it. // We use the "empty" GTMUnitTestingTestController controller so that // initWithWindowNibName can find the appropriate bundle to load our nib from. // For some reason when running unit tests, with all the injecting going on @@ -69,24 +58,24 @@ NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow"; // set up our delegates so we can test delegate handling GTMUnitTestingDelegate *appDelegate = [[GTMUnitTestingDelegate alloc] init]; [NSApp setDelegate:appDelegate]; - + // Get our window - GTMUnitTestingTestController *testWindowController + GTMUnitTestingTestController *testWindowController = [[GTMUnitTestingTestController alloc] initWithWindowNibName:kGTMWindowNibName]; NSWindow *window = [testWindowController window]; // Test the app state. This will cover windows and menus - GTMAssertObjectStateEqualToStateNamed(NSApp, - @"GTMUnitTestingTestApp", + GTMAssertObjectStateEqualToStateNamed(NSApp, + @"GTMUnitTestingTestApp", @"Testing the app state"); - - // Test the window image and state - GTMAssertObjectEqualToStateAndImageNamed(window, - kGTMWindowSaveFileName, + + // Test the window image and state + GTMAssertObjectEqualToStateAndImageNamed(window, + kGTMWindowSaveFileName, @"Testing the window image and state"); - + // Verify that all of our delegate encoders got called STAssertTrue([appDelegate didEncode], @"app delegate didn't get called?"); - + // Clean up [NSApp setDelegate:nil]; [appDelegate release]; @@ -95,10 +84,10 @@ NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow"; - (void)testViewUnitTesting { GTMUnitTestingView *unitTestingView = [[GTMUnitTestingView alloc] init]; - GTMAssertDrawingEqualToImageNamed(unitTestingView, - NSMakeSize(200,200), - @"GTMUnitTestingView", - NSApp, + GTMAssertDrawingEqualToImageNamed(unitTestingView, + NSMakeSize(200,200), + @"GTMUnitTestingView", + NSApp, @"Testing view drawing"); STAssertTrue([unitTestingView hadGoodContext], @"bad context?"); [unitTestingView release]; @@ -123,33 +112,33 @@ NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow"; NSString *originalPath = [NSObject gtm_getUnitTestSaveToDirectory]; STAssertNotNil(originalPath, @"No save dir?"); [NSObject gtm_setUnitTestSaveToDirectory:tempDir]; - STAssertEqualObjects(tempDir, [NSObject gtm_getUnitTestSaveToDirectory], + STAssertEqualObjects(tempDir, [NSObject gtm_getUnitTestSaveToDirectory], @"Save to dir not set?"); NSString *statePath = [self gtm_saveToPathForStateNamed:bogusTestName]; STAssertNotNil(statePath, @"no state path?"); NSString *imagePath = [self gtm_saveToPathForImageNamed:bogusTestName]; STAssertNotNil(imagePath, @"no image path?"); - GTMUnitTestingTestController *testWindowController + GTMUnitTestingTestController *testWindowController = [[GTMUnitTestingTestController alloc] initWithWindowNibName:kGTMWindowNibName]; NSWindow *window = [testWindowController window]; - + // Test against a golden master filename that doesn't exist expectedFailureCount_ = 2; GTMAssertObjectEqualToStateAndImageNamed(window, bogusTestName, @"Creating image and state files"); - STAssertEquals(expectedFailureCount_, 0, + STAssertEquals(expectedFailureCount_, 0, @"Didn't get expected failures creating files"); - + // Change our image and state and verify failures [[testWindowController textField] setStringValue:@"Foo"]; expectedFailureCount_ = 2; - GTMAssertObjectEqualToStateAndImageNamed(window, - kGTMWindowSaveFileName, + GTMAssertObjectEqualToStateAndImageNamed(window, + kGTMWindowSaveFileName, @"Testing the window image and state"); - STAssertEquals(expectedFailureCount_, 0, + STAssertEquals(expectedFailureCount_, 0, @"Didn't get expected failures testing files"); - + // Now change the size of our image and verify failures NSRect oldFrame = [window frame]; NSRect newFrame = oldFrame; @@ -157,45 +146,45 @@ NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow"; [window setFrame:newFrame display:YES]; expectedFailureCount_ = 1; GTMAssertObjectImageEqualToImageNamed(window, - kGTMWindowSaveFileName, + kGTMWindowSaveFileName, @"Testing the changed window size"); - [window setFrame:oldFrame display:YES]; - + [window setFrame:oldFrame display:YES]; + // Set our unit test save dir to a bogus directory and // run the tests again. [NSObject gtm_setUnitTestSaveToDirectory:@"/zim/blatz/foo/bob/bar"]; expectedFailureCount_ = 2; - GTMAssertObjectEqualToStateAndImageNamed(window, - kGTMWindowSaveFileName, + GTMAssertObjectEqualToStateAndImageNamed(window, + kGTMWindowSaveFileName, @"Testing the window image and state"); - STAssertEquals(expectedFailureCount_, 0, - @"Didn't get expected failures testing files"); + STAssertEquals(expectedFailureCount_, 0, + @"Didn't get expected failures testing files"); expectedFailureCount_ = 2; - GTMAssertObjectEqualToStateAndImageNamed(window, - @"GTMUnitTestingWindowDoesntExist", + GTMAssertObjectEqualToStateAndImageNamed(window, + @"GTMUnitTestingWindowDoesntExist", @"Testing the window image and state"); - STAssertEquals(expectedFailureCount_, 0, - @"Didn't get expected failures testing files"); - + STAssertEquals(expectedFailureCount_, 0, + @"Didn't get expected failures testing files"); + // Reset our unit test save dir [NSObject gtm_setUnitTestSaveToDirectory:nil]; - + // Test against something that doesn't have an image expectedFailureCount_ = 1; - GTMAssertObjectImageEqualToImageNamed(@"a string", - @"GTMStringsDontHaveImages", + GTMAssertObjectImageEqualToImageNamed(@"a string", + @"GTMStringsDontHaveImages", @"Testing that strings should fail"); - STAssertEquals(expectedFailureCount_, 0, @"Didn't get expected failures testing files"); - + STAssertEquals(expectedFailureCount_, 0, @"Didn't get expected failures testing files"); + // Test against something that doesn't implement our support expectedFailureCount_ = 1; GTMUnitTestingProxyTest *proxy = [[GTMUnitTestingProxyTest alloc] init]; - GTMAssertObjectStateEqualToStateNamed(proxy, - @"NSProxiesDontDoState", + GTMAssertObjectStateEqualToStateNamed(proxy, + @"NSProxiesDontDoState", @"Testing that NSProxy should fail"); - STAssertEquals(expectedFailureCount_, 0, @"Didn't get expected failures testing proxy"); + STAssertEquals(expectedFailureCount_, 0, @"Didn't get expected failures testing proxy"); [proxy release]; - + [window close]; } @@ -235,7 +224,7 @@ NSString *const kGTMWindowSaveFileName = @"GTMUnitTestingWindow"; return didEncode_; } @end - + @implementation GTMUnitTestingView - (void)gtm_unitTestViewDrawRect:(NSRect)rect contextInfo:(void*)contextInfo { |