如何在不点击"运行"按钮的情况下启动GHUnit测试?

use*_*101 6 unit-testing objective-c gh-unit

我使用GHUnit框架来测试静态库.此时我需要点击Run按钮开始我的测试.但是我想在启动应用程序时启动测试,因为我需要teamcity启动我的testApp.那么如何修改标准UI并自动启动测试呢?

Phi*_*ppe -1

使您的单元测试目标依赖于您的应用程序,以便您始终在单元测试之前构建应用程序。

然后,只需添加一个“setUp()”方法来启动您的应用程序(并等待它启动),然后再继续。

  1. 检查您的应用程序是否已在运行:

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

  2. 启动您的应用程序(在 setUP() 中)并等待:

    [[NSWorkspace共享工作空间]launchAppWithBundleIdentifier:com.mycompany.myapp选项:NSWorkspaceLaunchWithoutActivationadditionalEventParamDescriptor:NULL launchIdentifier:nil]; while (![self isRunning]) // 见上文 { sleep(1); }