【问题标题】:GHUnit - Terminal - "BAD CPU type in executable"GHUnit - 终端 - “可执行文件中的错误 CPU 类型”
【发布时间】:2013-12-14 07:22:24
【问题描述】:

在终端上运行的 GHUnit 脚本显示 "BAD CPU type in executable" 。它通过 XCode 在设备和模拟器上执行,但在终端上显示 CPU 错误。

参考:http://gabriel.github.io/gh-unit/docs/appledoc_include/guide_command_line.html 尝试重置设备网络设置

使用 Xcode5、iOS7 和 Wifi 网络

还有没有其他方法可以通过命令行运行 ghunit 测试脚本?

【问题讨论】:

  • 以 chmod u+X 方式执行 RunScript.sh 时,未显示“BAD cpu type executable”错误。而是构建通过了,但应用程序没有运行

标签: ios unit-testing xcode5


【解决方案1】:

确保您使用的是模拟器而不是真实设备,并且有效的拱门还包括 i386。

来自我的blog

我找到了一个很好的解决方法,适用于我的模拟器。 只需更改 main.m:

#import <UIKit/UIKit.h>
#import <GHUnitIOS/GHUnitIOSViewController.h>

int main(int argc, char *argv[])
{
    int retVal;
    @autoreleasepool {
        if (getenv("GHUNIT_CLI")) {
            retVal = [GHTestRunner run];
        } else {
            retVal = UIApplicationMain(argc, argv, nil, @"GHUnitIOSAppDelegate");
        }
    }
    return retVal;
}

已编辑:我成功从命令行在设备上运行,步骤如下:


来自我的blog

  1. 使用工具ideviceinstaller 安装到您的设备中

    ideviceinstaller -i &lt;your app&gt;.ipa

  2. 获取设备中的应用程序文件夹(以保留xml文件)

    app_path=ideviceinstaller -l -o xml | grep &lt;your app&gt;.app | sed 's/.*&lt;string&gt;\(.*\)&lt;your app&gt;.app&lt;\/string&gt;/\1/'

  3. 在设备中运行测试应用程序(不要保存在 tmp 文件夹中,归档时 tmp 文件夹会被删除)并将 XML 保存到“Caches”文件夹中。 (使用idevice-app-runnner工具)

    idevice-app-runner -s com.&lt;org&gt;.&lt;your scheme&gt; -DGHUNIT_CLI=YES -DGHUNIT_AUTORUN=YES -DGHUNIT_AUTOEXIT=YES -DWRITE_JUNIT_XML=YES -DJUNIT_XML_DIR=$app_path/Library/Caches/test-results

  4. 从设备获取存档应用程序(以提取 xml 文件)- 测试应用程序完成后运行

    ideviceinstaller -a com.&lt;org&gt;.&lt;your scheme&gt; -o copy=. -o remove

  5. mv com.&lt;org&gt;.&lt;your app&gt;.ipa &lt;any app name&gt;.zip

  6. unzip -o &lt;any app name&gt;.zip

  7. cp Container/Library/Caches/test-results/*.* &lt;your folder to keep the result xml files&gt;

【讨论】:

  • 以 chmod u+X 方式执行 RunScript.sh 时,未显示“BAD cpu type executable”错误。而是构建通过了,但应用程序没有运行
  • 如果没有 chmod u+X,它在模拟器中可以正常工作。但在设备上显示“Bad cpu type error”。有没有其他方法可以在终端上运行 Ghunit 从而与 Jenkins 集成
  • 在设备上运行时,不需要 RunTests.sh,但需要按上述方式运行应用程序(注意:xml 结果存储在设备上的应用程序文件夹中):idevice-app -runner -s com.. -DGHUNIT_CLI=YES -DGHUNIT_AUTORUN=YES -DGHUNIT_AUTOEXIT=YES -DWRITE_JUNIT_XML=YES -DJUNIT_XML_DIR=$app_path/Library/Caches/test-results
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多