白盒测试 Jenkins 集成 xctool 执行 iOS 单元测试模拟器无法启动

小明 · February 08, 2015 · Last by Bluelipper replied at September 26, 2016 · 1715 hits

环境:
Jenkins搭建在Mac服务器上面,安装在tomcat当中以webapp方式启动。
mac系统版本:10.9.4
xctool版本:0.2.2
jenkins版本:1.598

现象:
在mac本机执行测试通过,使用jenkins shell方式执行失败,模拟器启动后显示黑屏。

测试命令:
xctool -project Sample.xcodeproj -scheme SampleTests -sdk iphonesimulator test -freshInstall -freshSimulator

错误日志如下:

--------------------------------------------------------------------------------
iOS deployment target '8.1' for architecture 'i386' and variant 'normal' is greater than the maximum value '8.0.99' for the Simulator - iOS 8.0 SDK.
--------------------------------------------------------------------------------
~ Write auxiliary files (3 ms)
--------------------------------------------------------------------------------
/bin/mkdir -p /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build
write-file /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/SampleTests-project-headers.hmap
write-file /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/SampleTests-generated-files.hmap
write-file /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/SampleTests-all-target-headers.hmap
write-file /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/SampleTests-own-target-headers.hmap
write-file /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/SampleTests.hmap
write-file /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/SampleTests-all-non-framework-target-headers.hmap
/bin/mkdir -p /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/Objects-normal/i386
write-file /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Intermediates/Sample.build/Debug-iphonesimulator/SampleTests.build/Objects-normal/i386/SampleTests.LinkFileList
--------------------------------------------------------------------------------
~ Create product structure (0 ms)
--------------------------------------------------------------------------------
/bin/mkdir -p /Users/wangmy/Library/Developer/Xcode/DerivedData/Sample-haasvciuwqzzcociidumavsvdwoo/Build/Products/Debug-iphonesimulator/SampleTests.xctest
--------------------------------------------------------------------------------
~ Process Info.plist (3 ms)
~ Compile CSSTests.mm (1461 ms)
~ Compile HistoryManageTests.mm (1002 ms)
~ Compile RenderTests.mm (1260 ms)
~ Compile ERTLuaCoreUnitTests.mm (616 ms)
~ Compile ERTCoreTests.mm (346 ms)
~ Link SampleTests (30 ms)
~ Generate SampleTests.xctest.dSYM (53 ms)
~ Touch SampleTests.xctest (2 ms)
0 errored, 1 warning (1566 ms)


[Info] Collecting info for testables... (1584 ms)
run-test SampleTests.xctest (iphonesimulator8.0, application-test)
[Warning] Tried to install the test host app 'net.light.sample' but failed. (63 ms)
[Info] Preparing test environment failed; will retry 2 more times (0 ms)
[Info] Verified iOS Simulators... (0 ms)
[Info] Shut down iOS Simulator... (0 ms)
[Info] Stopped any existing iOS simulator jobs to get a fresh simulator. (123 ms)
[Info] Reset iOS simulator content and settings at path "/Users/wangmy/Library/Developer/CoreSimulator/Devices/2EE9285F-1031-4A63-BE94-F1395C79C083/data" (541 ms)
[Warning] Tried to install the test host app 'net.light.sample' but failed. (15 ms)
[Info] Preparing test environment failed; will retry 1 more time (0 ms)
[Info] Verified iOS Simulators... (0 ms)
[Info] Shut down iOS Simulator... (0 ms)
[Info] Stopped any existing iOS simulator jobs to get a fresh simulator. (128 ms)
[Info] Reset iOS simulator content and settings at path "/Users/wangmy/Library/Developer/CoreSimulator/Devices/2EE9285F-1031-4A63-BE94-F1395C79C083/data" (592 ms)
[Warning] Tried to install the test host app 'net.light.sample' but failed. (15 ms)
[Warning] Preparing test environment failed. (0 ms)
-[TEST_BUNDLE FAILED_TO_START]
--------------------------------------------------------------------------------
There was a problem starting the test bundle: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[TEST_BUNDLE FAILED_TO_START] (0 ms) (0)
-[CSSTests testCSSCreate]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[CSSTests testCSSCreate] (0 ms) (1)
-[CSSTests testCSSParser]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[CSSTests testCSSParser] (0 ms) (2)
-[CSSTests testColorParser]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[CSSTests testColorParser] (0 ms) (3)
-[CSSTests testPerformanceExample]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[CSSTests testPerformanceExample] (0 ms) (4)
-[ERTCoreTests testExample]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[ERTCoreTests testExample] (0 ms) (5)
-[ERTCoreTests testPerformanceExample]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[ERTCoreTests testPerformanceExample] (0 ms) (6)
-[HistoryManageTests testHistoryManage]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[HistoryManageTests testHistoryManage] (0 ms) (7)
-[RenderTests testCreateRender]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[RenderTests testCreateRender] (0 ms) (8)
-[RenderTests testPerformanceExample]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[RenderTests testPerformanceExample] (0 ms) (9)
-[RenderTests testRenderTree]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[RenderTests testRenderTree] (0 ms) (10)
-[RenderTests testSetInnerHtml]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
----|---------------------------------------------------------------------------
X -[RenderTests testSetInnerHtml] (0 ms) (11)
0 passed, 0 failed, 12 errored, 12 total (1 ms)


Failures:

0) -[TEST_BUNDLE FAILED_TO_START] (SampleTests.xctest)
--------------------------------------------------------------------------------
There was a problem starting the test bundle: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

1) -[CSSTests testCSSCreate] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

2) -[CSSTests testCSSParser] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

3) -[CSSTests testColorParser] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

4) -[CSSTests testPerformanceExample] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

5) -[ERTCoreTests testExample] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

6) -[ERTCoreTests testPerformanceExample] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

7) -[HistoryManageTests testHistoryManage] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

8) -[RenderTests testCreateRender] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

9) -[RenderTests testPerformanceExample] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

10) -[RenderTests testRenderTree] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

11) -[RenderTests testSetInnerHtml] (SampleTests.xctest)
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.
--------------------------------------------------------------------------------

** TEST FAILED: 0 passed, 0 failed, 12 errored, 12 total ** (77259 ms)
共收到 15 条回复 时间 点赞

不太懂ios测试,但是你上面的出错信息说的是你的应用没有安装

Tried to install the test host app 'net.light.sample' but failed

#1楼 @doctorq 本地执行是可通过的,就是能启动模拟器执行测试的,但是通过ssh和jenkins就会失败。

#2楼 @mingyuwang 这个不能这么暗示自己,不是说一次执行成功,就说明它应该成功,这就是bug存在的原因。感觉是你的远程集成环境中启动模拟器没弄好,既然知道原因,可以仔细检查下。

#3楼 @doctorq 不是这个意思,是在mac本地执行是一直通过的,但是通过ssh和jenkins是一直不通过,两种情况下的结果不同。主要想问一下有没有人碰到类似的问题,有没有什么解决的思路。

锅锅,你版本不兼容啊,你仔细读下第一句。iOS deployment target '8.1' for architecture 'i386' and variant 'normal' is greater than the maximum value '8.0.99' for the Simulator - iOS 8.0 SDK.

会不会是由于jenkins里面使用的用户不一样?用户不一样会导致各种设置不一样的。我在windows下用jenkins经常遇到这个问题,本地跑得好好的脚本去到jenkins各种报错。但mac里面没用过,不是很清楚是不是也是一样的。

#6楼 @beerbox No,版本不兼容的话,本地是运行不起来的

#7楼 @chenhengjie123 用户和本地使用的是相同的,都是管理员用户

@mingyuwangxctool找到一段说明
In order to your run your tests within a continuous integration environment, you must create Shared Schemes for your application target and ensure that all dependencies (such as CocoaPods) are added explicitly to the Scheme
这一部分有做了吗?

小明 #11 · February 09, 2015 作者

#10楼 @chenhengjie123 有做Shared Schemes ,这个是xcode里面配置好的,直接获取源码就有

@mingyuwang 能把正常跑得通的log贴上来一下吗?到

----|---------------------------------------------------------------------------
X -[TEST_BUNDLE FAILED_TO_START] (0 ms) (0)
-[CSSTests testCSSCreate]
--------------------------------------------------------------------------------
Test did not run: Simulator 'iPhone 4s' was not prepared: Failed for unknown reason.

这里就可以了。
估计还是因为jenkins建立的shell和你能执行成功的shell部分配置不一样。

小明 #13 · February 09, 2015 作者

#12楼 @chenhengjie123 执行正常的shell输出:

[Info] Collecting info for testables... (1402 ms)
run-test SampleTests.xctest (iphonesimulator8.0, application-test)
[Info] Verified iOS Simulators... (0 ms)
[Info] Shut down iOS Simulator... (273 ms)
[Info] Stopped any existing iOS simulator jobs to get a fresh simulator. (125 ms)
[Info] Uninstalled 'net.light.sample' to get a fresh install. (2866 ms)
[Info] Installed 'net.light.sample'. (881 ms)
[Info] Launching test host and running tests ... (0 ms)
小明 #14 · February 09, 2015 作者

#12楼 @chenhengjie123

 -[RenderTests testSetInnerHtml] (1 ms)
11 passed, 0 failed, 0 errored, 11 total (845 ms)

@mingyuwang have you fixed? I have just met the same problem :(

需要 Sign In 后方可回复, 如果你还没有账号请点击这里 Sign Up