Generate gcda-files with Xcode5, iOS7 simulator and XCTest

前端 未结 6 1272
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 06:09

Being inspired by the solution to this question I tried using the same approach with XCTest.

I\'ve set \'Generate Test Coverage Files=YES\' and \'Instrument Program

6条回答
  •  囚心锁ツ
    2020-12-02 06:40

    The process for this is a little different if you're using Specta, since it does its own swizzling. The following is working for me:

    Test Bundle:

    @interface MyReporter : SPTNestedReporter // keeps the default reporter style
    @end
    
    @implementation MyReporter
    
    - (void) stopObserving
    {
      [super stopObserving];
      UIApplication* application = [UIApplication sharedApplication];
      [application.delegate applicationWillTerminate:application];
    }
    
    @end
    

    AppDelegate:

    - (void)applicationWillTerminate:(UIApplication *)application
    {
    #ifdef DEBUG
      extern void __gcov_flush(void);
      __gcov_flush();
    #endif
    }
    

    You then need to enable your custom reporter subclass by setting the environmental variable SPECTA_REPORTER_CLASS to MyReporter in the Run section of your main scheme.

提交回复
热议问题