Skip to content

Commit

Permalink
Merge pull request #360 from pivotal/xctoolIntegration
Browse files Browse the repository at this point in the history
Adjust XCTest integration such that xctool finds Cedar specs
  • Loading branch information
briancroom committed Oct 7, 2015
2 parents e76af34 + e01a43b commit 51faf7f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Source/Headers/Project/XCTest/CDRXCTestSupport.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

// XCTestSuite

- (id)defaultTestSuite;
- (id)CDR_original_defaultTestSuite;
- (id)allTests;
- (id)CDR_original_allTests;
- (id)initWithName:(NSString *)aName;

// XCTestObservationCenter
Expand Down
10 changes: 4 additions & 6 deletions Source/XCTest/CDRXCTestFunctions.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,16 @@ void CDRInjectIntoXCTestRunner() {
static CDRXCTestObserver *xcTestObserver;
xcTestObserver = [[CDRXCTestObserver alloc] init];
[observationCenter addTestObserver:xcTestObserver];

return;
}

Class testSuiteMetaClass = object_getClass(testSuiteClass);
Method m = class_getClassMethod(testSuiteClass, @selector(defaultTestSuite));
Method m = class_getClassMethod(testSuiteClass, @selector(allTests));

class_addMethod(testSuiteMetaClass, @selector(CDR_original_defaultTestSuite), method_getImplementation(m), method_getTypeEncoding(m));
class_addMethod(testSuiteMetaClass, @selector(CDR_original_allTests), method_getImplementation(m), method_getTypeEncoding(m));
IMP newImp = imp_implementationWithBlock(^id(id self){
id defaultSuite = [self CDR_original_defaultTestSuite];
id defaultSuite = [self CDR_original_allTests];
[defaultSuite addTest:CDRCreateXCTestSuite()];
return defaultSuite;
});
class_replaceMethod(testSuiteMetaClass, @selector(defaultTestSuite), newImp, method_getTypeEncoding(m));
class_replaceMethod(testSuiteMetaClass, @selector(allTests), newImp, method_getTypeEncoding(m));
}

0 comments on commit 51faf7f

Please sign in to comment.