开发者

How start GHUnit tests without tapping Run button?

开发者 https://www.devze.com 2023-02-22 04:07 出处:网络
I use GHUnit framework for testing static library. At this moment I need tap the button Run to star开发者_开发问答t my tests. But I would like to start tests when application launched because I need t

I use GHUnit framework for testing static library. At this moment I need tap the button Run to star开发者_开发问答t my tests. But I would like to start tests when application launched because I need teamcity launch my testApp. So how can I modified standart UI and start tests automatic?


Do Product -> Edit Scheme… -> Arguments -> Environment Variables, then set GHUNIT_AUTORUN to YES.


Make your unit test target dependent on your application, so that you always built the application before the unit tests.

Then, simply add a "setUp()" method to launch your app (and wait for it to be launched) before continuing.

  1. Check that your application is already running:

    NSArray* apps = [[NSWorkspace sharedWorkspace] valueForKeyPath:@"launchedApplications.NSApplicationBundleIdentifier"]; BOOL myAppIsRunning = [apps containsObject: com.mycompany.myapp];

  2. Launch your application (in setUP()) and wait:

    [[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier: com.mycompany.myapp options: NSWorkspaceLaunchWithoutActivation additionalEventParamDescriptor: NULL launchIdentifier: nil]; while (![self isRunning]) // see above { sleep(1); }

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号