2015-10-27 20:59:15 +00:00
|
|
|
/* Copyright 2015 Realm Inc - All Rights Reserved
|
|
|
|
* Proprietary and Confidential
|
|
|
|
*/
|
2015-08-13 16:12:48 +00:00
|
|
|
|
2015-10-06 07:57:35 +00:00
|
|
|
#import <objc/runtime.h>
|
|
|
|
|
2015-08-13 16:12:48 +00:00
|
|
|
#import "RealmJSTests.h"
|
|
|
|
|
2015-10-15 18:34:24 +00:00
|
|
|
@implementation RealmJSTests
|
2015-09-28 23:05:57 +00:00
|
|
|
|
2015-10-15 18:34:24 +00:00
|
|
|
+ (NSArray *)testSuitesFromDictionary:(NSDictionary *)testCaseNames {
|
|
|
|
NSMutableArray *testSuites = [[NSMutableArray alloc] init];
|
2015-09-28 23:05:57 +00:00
|
|
|
|
2015-10-15 18:34:24 +00:00
|
|
|
for (NSString *suiteName in testCaseNames) {
|
|
|
|
XCTestSuite *testSuite = [[XCTestSuite alloc] initWithName:suiteName];
|
|
|
|
Class testClass = objc_allocateClassPair(self, suiteName.UTF8String, 0);
|
2015-09-28 23:05:57 +00:00
|
|
|
|
2015-10-15 18:34:24 +00:00
|
|
|
for (NSString *testName in testCaseNames[suiteName]) {
|
|
|
|
XCTestCase *testCase = [[testClass alloc] initWithTestName:testName];
|
|
|
|
[testSuite addTest:testCase];
|
|
|
|
}
|
2015-08-13 16:12:48 +00:00
|
|
|
|
2015-10-15 18:34:24 +00:00
|
|
|
[testSuites addObject:testSuite];
|
2015-10-06 07:57:35 +00:00
|
|
|
}
|
|
|
|
|
2015-10-15 18:34:24 +00:00
|
|
|
return [testSuites copy];
|
2015-10-06 07:57:35 +00:00
|
|
|
}
|
|
|
|
|
2015-10-15 18:34:24 +00:00
|
|
|
- (instancetype)initWithTestName:(NSString *)name {
|
|
|
|
return [super initWithSelector:NSSelectorFromString(name)];
|
2015-08-13 16:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setUp {
|
|
|
|
[super setUp];
|
|
|
|
|
2015-10-14 21:58:42 +00:00
|
|
|
[self invokeMethod:@"beforeEach"];
|
2015-08-13 16:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)tearDown {
|
2015-10-14 21:58:42 +00:00
|
|
|
[self invokeMethod:@"afterEach"];
|
|
|
|
|
2015-08-13 16:12:48 +00:00
|
|
|
[super tearDown];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)invokeTest {
|
|
|
|
@autoreleasepool {
|
|
|
|
[super invokeTest];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector {
|
|
|
|
NSMethodSignature *sig = [super methodSignatureForSelector:aSelector];
|
2015-10-06 07:57:35 +00:00
|
|
|
return sig ?: [NSMethodSignature signatureWithObjCTypes:"v@:"];
|
2015-08-13 16:12:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)forwardInvocation:(NSInvocation *)anInvocation {
|
2015-10-14 21:58:42 +00:00
|
|
|
[self invokeMethod:NSStringFromSelector(anInvocation.selector)];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)invokeMethod:(NSString *)method {
|
2015-10-15 18:34:24 +00:00
|
|
|
[self doesNotRecognizeSelector:_cmd];
|
2015-08-14 17:47:56 +00:00
|
|
|
}
|
|
|
|
|
2015-08-13 16:12:48 +00:00
|
|
|
@end
|