diff options
author | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-09-16 17:04:27 +0000 |
---|---|---|
committer | gtm.daemon <gtm.daemon@7dc7ac4e-7543-0410-b95c-c1676fc8e2a3> | 2009-09-16 17:04:27 +0000 |
commit | 080b28284751ae178608f45268765f6e0ae94287 (patch) | |
tree | 615c076d5a79621921eac431f5857f6e2d73c8c0 /UnitTesting/GTMSenTestCase.m | |
parent | 9ebf8b15cfb105864e97a0e8b005de8e6e5d5c42 (diff) |
[Author: dmaclach]
Add support for more complex unit test class hierarchies than what is
available out of the box in SenTestCase. I currently have the release notes
checked out as part of a separate change, and will update them accordingly
for this as well.
R=thomasvl,mrossetti
DELTA=80 (79 added, 0 deleted, 1 changed)
Diffstat (limited to 'UnitTesting/GTMSenTestCase.m')
-rw-r--r-- | UnitTesting/GTMSenTestCase.m | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/UnitTesting/GTMSenTestCase.m b/UnitTesting/GTMSenTestCase.m index 99b9db0..ec5ef62 100644 --- a/UnitTesting/GTMSenTestCase.m +++ b/UnitTesting/GTMSenTestCase.m @@ -18,6 +18,7 @@ #import "GTMSenTestCase.h" #import <unistd.h> +#import "GTMObjC2Runtime.h" #if !GTM_IPHONE_SDK #import "GTMGarbageCollection.h" @@ -305,6 +306,36 @@ NSString *const SenTestLineNumberKey = @"SenTestLineNumberKey"; [devLogClass performSelector:@selector(disableTracking)]; } } + ++ (BOOL)isAbstractTestCase { + int numClasses = objc_getClassList(NULL, 0); + BOOL isAbstract = NO; + if (numClasses > 0) { + Class *classes = malloc(sizeof(Class) * numClasses); + numClasses = objc_getClassList(classes, numClasses); + for (int i = 0; i < numClasses && !isAbstract; ++i) { + Class cls = classes[i]; + if (class_respondsToSelector(cls, @selector(superclass))) { + Class superClass = [cls superclass]; + if ([self isEqualTo:superClass]) { + isAbstract = YES; + } + } + } + free(classes); + } + return isAbstract; +} + + ++ (NSArray *)testInvocations { + NSArray *invocations = nil; + if (![self isAbstractTestCase]) { + invocations = [super testInvocations]; + } + return invocations; +} + @end // Leak detection |