XCode 5 Testing symbol “rT” means what?

前端 未结 4 412
日久生厌
日久生厌 2020-12-13 09:27

I have 2 test classes in a XCode 5 project:

ABCDataModelTests.{h,m}

- (void)testAlwaysPassing { ... }

ABCDataModelListColorsTests.m

4条回答
  •  囚心锁ツ
    2020-12-13 09:39

    Deleting derived data didn't help me to get rid of running these tests. So I've created a small category on XCTestCase and it worked:

    #import "XCTestCase+TestCaseSwizzling.h"
    @import ObjectiveC.runtime;
    
    static NSMutableSet* alreadyRunTests = nil;
    
    @implementation XCTestCase (TestCaseSwizzling)
    
    + (void)load
    {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
    
        alreadyRunTests = [NSMutableSet set];
    
        Class class = [self class];
    
        SEL originalSelector = @selector(invokeTest);
        SEL swizzledSelector = @selector(swizzledInvokeTest);
    
        Method originalMethod = class_getInstanceMethod(class, originalSelector);
        Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
    
        method_exchangeImplementations(originalMethod, swizzledMethod);
    });
    }
    
    - (void)swizzledInvokeTest
    {
         NSString* selectorString = NSStringFromSelector(self.invocation.selector);
    
         if (![alreadyRunTests containsObject:selectorString])
         {
             [alreadyRunTests addObject:selectorString];
             [self swizzledInvokeTest];
         }
     }
    
     @end
    

提交回复
热议问题