XCode 5 unit testing: starts my app

前端 未结 7 1744
挽巷
挽巷 2020-11-29 23:04

When I run my tests in XCode 5, the main window of my OS X app appears on the screen for a couple of seconds while running the tests. Why? Even if I uncomment all my tests i

相关标签:
7条回答
  • 2020-11-29 23:53

    In XCode 7, removing Host Application does not work for me. Indeed I use the following to avoid app runs.

    1. Setup Test Scheme Arguments

    2. in main.m

      static bool isRunningTests()
      {
          NSDictionary* environment = [[NSProcessInfo processInfo] environment];
          NSString* testEnabled = environment[@"TEST_ENABLED"];
          return [testEnabled isEqualToString:@"YES"];
      }
      
    3. modify main()

      int main(int argc, char * argv[]) {
          @autoreleasepool {
              if (isRunningTests()) {
                  return UIApplicationMain(argc, argv, nil, nil);
              } else {
                  return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
              }
          }
      }
      
    0 讨论(0)
提交回复
热议问题