开源测试工具 fastmonkey 自我扫盲贴

yxys01 · 2017年08月24日 · 最后由 westwind 回复于 2018年06月14日 · 2684 次阅读
本帖已被设为精华帖!

基于 XCTestWD,swiftmonkey 二次开发,实现无需插桩的 iOS monkey 自动化工具 fastmonkey

优势

无需插桩!
高效率,每秒4-5个action!
轻量极简!

原理

先致敬两个开源工具;

1.swiftmonkey
       https://github.com/zalando/SwiftMonkey
       因其直接使用了 苹果的私有api 如XCEventGenerator.tapAtTouchLocations 故执行速度极快。同时也用类似android monkey的事件生成机制,自身源源不断的产生如 tap,swipe,pinchIn等事件使其对被测app产生了极大的压力
       缺点:需要插桩
2.XCTestWD
       https://github.com/macacajs/XCTestWD
       类似facebook wda的方式,在xcode中执行xcuitest时启动一个监听server,可通过外部发送命令来创建待测app对应session并启动app,同时也实现了dump tree 和依据xpath,id等来定位某个控件并操作这些控件
3.Fastmonkey
       (https://github.com/zhangzhao4444/Fastmonkey
       结合两者优点并改造两者,在XCTestWD基础上实现一个server路由,外部命令时可引导启动app 并执行monkey

       首先感谢来自熊猫tv的大佬@zhangzhao_lenovo的无私贡献,开源给我们社区使用,这基本算UIAutomation被遗弃后,第一款无须注入就能使用的iOS monkey测试的工具了,给zhangzhao_lenovo大佬点赞。其次感谢macaca团队的@SamuelZhaoY @xdf 大佬们(ps:肯定还有其他大佬,这里我只把XCTestWD的作者,和我们最熟悉的达峰大佬@出来了,希望其他大佬不要在意),给我们做自动化测试的人员提供那么好用的macaca,以及他们自己写的可以用来代替WDA的XCTestWD,我代替伸手党们对你们表示感谢。

废话不多说了,今天我开始使用Fastmonkey,最开始配置有点小问题,但是很快在zhangzhao_lenovo大佬以及@Only7的帮助下解决了,这里我来写个扫盲贴(安装贴?)

第一步:打开终端,git clone下来(其他方式皆可)

$ git clone https://github.com/zhangzhao4444/Fastmonkey.git

第二步:因为我是直接git下来的,Fastmonkey在我的/Users/xxxxx/Fastmonkey路径下,接下来我们更新依赖包.

先定位到XCTestWD-master下

$ cd /Users/xxxxx/Fastmonkey/XCTestWD-master

cartfile安装第三方库

$ carthage update

第三步:第三方库下载好,开始配置XCTestWD.xcodeproj。我们用Xcode打开XCTestWD.xcodeproj,然后来配置XCTestWD里面的一些内容

首先是XCTestWD->General->Signing->Team,把账号设置好,具体可以见XCTestWD的配置,保证不报错。

当然XCTestWDUITests->General->Signing->Team也一样

然后在XCTestWD->Build Setting->Header Search Paths和XCTestWD->Build Setting->Objective-C Bridging Header中,把里面的XCTestWD/XCTestWD-Bridging-Header.h删掉。
理由见下面。

第四步:环境配置好了,就是运行了,我这里就直接用真机来运行的。

首先,打开一个终端窗口,执行:

$ iproxy 8001 8001

接着,再打开一个终端窗口。执行:

$ cd /Users/xiatian/Fastmonkey/XCTestWD-master/XCTestWD 
$ xcodebuild -project XCTestWD.xcodeproj \
           -scheme XCTestWDUITests \
           -destination 'platform=iOS,name=(your device name)' \
           XCTESTWD_PORT=8001 \
           clean test

出现上面的页面,说明XCTestWD运行成功了

最后,打开第三个终端窗口,执行:

$curl -X POST -H "Content-Type:application/json" \
              -d "{\"desiredCapabilities\":{\"deviceName\":\"xxxx\",\"platformName\":\"iOS\", \"bundleId\":\"com.PandaTV.Live-iPhone\",\"autoAcceptAlerts\":\"false\"}}" \
              http://127.0.0.1:8001/wd/hub/monkey

你就可以看见你手机成功打开PandaTV,然后monkey似的在那乱点了~~~~

问题:

、error: bridging header '/Users/xxxxx/Fastmonkey/XCTestWD-master/XCTestWD/XCTestWD/XCTestWD-Bridging-Header.h' does not exist

原因:

xcode buildsetting有问题。 xctestwd中没有用到oc,swift混编,header search path,objecktive-c bridging header 配置可去掉再试试。xctestwduitest中用了混编才需要 xctestwduitest-bridging-header.h

解决方案:

XCTestWD->Build Setting->Header Search Paths和XCTestWD->Build Setting->Objective-C Bridging Header中,把里面的XCTestWD/XCTestWD-Bridging-Header.h删掉

、Swifter无法找到

原因:未安装第三方库

解决方案:

先定位到XCTestWD-master下

$ cd /Users/xxxxx/Fastmonkey/XCTestWD-master

cartfile安装第三方库

$ carthage update

、如果Mac插入多台iPhone设备

iproxy 8001 8001 后需要加serialid 指定哪台iPhone设备做端口映射。 然后curl 中执行对应iPhone设备

、xcodebuild方式跑起来的截图和crash日志在哪里找呢?

xcode里中断运行时 有个log路径的日志输出 xxx/XCTestWD-xxx/Logs/Test/Attentment

、crash log也是会生成在 Attachments文件夹里面吗? 该crash log是否可以追踪到app代码问题?

crash 也在Attachments里

就是系统生成的崩溃堆栈文件,研发有对应的符号文件是可以定位的

当然,最后再次感谢zhangzhao_lenovo大佬,该贴只为扫盲,解决一些小白的安装流程及问题,做了伸手党,也要帮大佬解决一点小问题嘛。

大佬原贴在此:https://testerhome.com/topics/9524

有难度的问题可以去该帖近距离触摸zhangzhao_lenovo大佬,没难度的就在这个帖子下面大家一起讨论吧。

照例,在最后@几个大神防止帖子沉下去。。。。

@seveniruby @xdf @zhangzhao_lenovo@Lihuazhang@pliue (ps:继续抱大腿活动)

2017-10-19更新

最近升级Xcode9和iOS11后,fastmonekey也受到一定影响,存在一些新的问题,大家可以看下这篇文章:https://testerhome.com/topics/10390,希望能帮助你们解决问题。

感谢@Test_Sir的贡献。

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!
共收到 42 条回复 时间 点赞
seveniruby 将本帖设为了精华贴 08月25日 06:42

学习学习

Mark ! 感谢分享!

5楼 已删除

请问下执行iproxy 8001 8001报错iproxy 找不到是什么原因,还有第二个和三个终端的deviceName就是苹果手机的udid吗

Code signing is required for product type 'UI Testing Bundle' in SDK 'iOS 10.3' 提示我这个 我应该怎么处理

hejianhao0612 回复

你是不是没有安装libimobiledevice啊?

hejianhao0612 回复

deviceName是你的设备名称啊

xcode->device->你的设备->name
一般是 XXX的 iPhone

yxys01 #10 · 2017年08月29日 作者
304764691 回复

xcode版本不够吧,升级xcode吧

执行到最后一步,提示找不到我的设备,但是错误日志里打出的列表中又有我的设备。。。
执行命令是:xcodebuild -project XCTestWD.xcodeproj -scheme XCTestWDUITests -destination 'platform=iOS,name=(“张圣洁”的 iPhone)' XCTESTWD_PORT=8001 clean test
错误日志:
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS, name:(“张圣洁”的 iPhone) }

The requested device could not be found because no available devices matched the request.

Available destinations for the "XCTestWDUITests" scheme:
{ platform:iOS, id:48ade89d767be26fa2d6a53eec51085e02e43ec6, name:“张圣洁”的 iPhone }
{ platform:iOS, id:537a954539a82db33ed879a4d500c70a8458de9c, name:yan的 iPhone }
{ platform:iOS Simulator, id:B896FC57-4760-4930-AB11-2D5C4E223769, OS:10.3.1, name:iPad (5th generation) }
{ platform:iOS Simulator, id:1662F473-A67B-4E6A-8971-651B16394D72, OS:10.3.1, name:iPad Air }
{ platform:iOS Simulator, id:6D42E5E7-0F33-4A20-9837-E0BADBBA8342, OS:10.3.1, name:iPad Air 2 }
{ platform:iOS Simulator, id:950FB86A-CDEC-40F0-8FF2-AC2800F884DF, OS:10.3.1, name:iPad Pro (9.7 inch) }
{ platform:iOS Simulator, id:0512C785-4C39-4F35-93DA-B383CC8510DE, OS:10.3.1, name:iPad Pro (10.5-inch) }
{ platform:iOS Simulator, id:CAFEDC20-E79F-4061-9E24-B55E37A353B1, OS:10.3.1, name:iPad Pro (12.9 inch) }
{ platform:iOS Simulator, id:745B0C59-04DF-43D8-B431-086F74CAD7A5, OS:10.3.1, name:iPad Pro (12.9-inch) (2nd generation) }
{ platform:iOS Simulator, id:C79D11A9-DFE7-43A9-9871-3C030360AD57, OS:10.3.1, name:iPhone 5 }
{ platform:iOS Simulator, id:85F607AE-C9C5-4230-A5F6-01361253BBBF, OS:10.3.1, name:iPhone 5s }
{ platform:iOS Simulator, id:6D792B46-0296-4332-B643-FAC2BCB485B4, OS:10.3.1, name:iPhone 6 }
{ platform:iOS Simulator, id:8F207306-E311-43A5-8826-76C526E1E54E, OS:10.3.1, name:iPhone 6 Plus }
{ platform:iOS Simulator, id:FAE72621-4D4D-40DB-B6A8-CB422F8ABBFD, OS:10.3.1, name:iPhone 6s }
{ platform:iOS Simulator, id:34B7D02E-DBFC-4BCB-94D9-013E9B34BE91, OS:10.3.1, name:iPhone 6s Plus }
{ platform:iOS Simulator, id:F5C83B6B-148B-4C5A-B6E6-E620DE0ACA60, OS:10.3.1, name:iPhone 7 }
{ platform:iOS Simulator, id:2E95E3EF-D2FB-4921-A613-27021378E2DA, OS:10.3.1, name:iPhone 7 Plus }
{ platform:iOS Simulator, id:46143C6D-A772-450C-A8E9-CA0B429650F6, OS:10.3.1, name:iPhone SE }

Ineligible destinations for the "XCTestWDUITests" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Generic iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Generic iOS Simulator Device }

运行xcodebuild -project XCTestWD.xcodeproj 这句报错:
2017-08-30 19:02:35.530 xcodebuild[41499:4750078] Error Domain=IDETestOperationsObserverErrorDomain Code=4 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/mac/Library/Developer/Xcode/DerivedData/XCTestWD-cseytoewhlzxivgopaonbuqulosj/Logs/Test/BBE6C2E9-EFFC-4AC7-BF69-A360B492C709/Session-XCTestWDUITests-2017-08-30_190230-J7U8QS.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /Users/mac/Library/Developer/Xcode/DerivedData/XCTestWD-cseytoewhlzxivgopaonbuqulosj/Logs/Test/BBE6C2E9-EFFC-4AC7-BF69-A360B492C709/Session-XCTestWDUITests-2017-08-30_190230-J7U8QS.log}

Testing failed:
Use of undeclared type 'XCTestWDMonkey'
Use of unresolved identifier 'XCTestWDMonkey'
** TEST FAILED **

The following build commands failed:
CompileSwift normal armv7 /Users/mac/Documents/Fastmonkey/XCTestWD-master/XCTestWD/XCTestWDUITests/XCTestWDRunner.swift
CompileSwiftSources normal armv7 com.apple.xcode.tools.swift.compiler
(2 failures)

yxys01 #15 · 2017年08月31日 作者
holyzhang 回复

你curl中设备名不要打引号啊,就像下面这个:

curl -X POST -H "Content-Type:application/json" \
              -d "{\"desiredCapabilities\":{\"deviceName\":\"XXX的 iPhone\",\"platformName\":\"iOS\", \"bundleId\":\"com.neudzf.CSDNBlog\",\"autoAcceptAlerts\":\"false\"}}" \
              http://127.0.0.1:8001/wd/hub/monkey

其次你先不要插两台设备,如果要并发的话,请参考原贴的回复 https://testerhome.com/topics/9524

{ platform:iOS, id:48ade89d767be26fa2d6a53eec51085e02e43ec6, name:“张圣洁”的 iPhone }
{ platform:iOS, id:537a954539a82db33ed879a4d500c70a8458de9c, name:yan的 iPhone }
16楼 已删除
17楼 已删除
yxys01 回复

我用xocode安装的xctestwd,然后curl的时候 链接的时候有问题
服务端:
Requesting connecion to device handle == 8 (serial: 48ade89d767be26fa2d6a53eec51085e02e43ec6), port 8001
Error connecting to device!
链接端:
curl: (52) Empty reply from server

yxys01 #19 · 2017年08月31日 作者
holyzhang 回复

首先是xcode不是xocode,你这代码注意点,别因为打错导致错误。
其次,你先按我写的指导教程一步一步的走嘛,先跑通,你再去用xcode run嘛。。。
最后,你这个是链接失败的错误,看看是不是端口没打开或者xctestwd没装好?
个人建议,你先按我的指导贴一步一步走一遍,看看是不是还有问题,再来提好吗?

yxys01 回复

求教,按照你的步骤执行,在执行到xcodebuild -project XCTestWD.xcodeproj -scheme XCTestWDUITests -destination 'platform=iOS,name=slideplus' XCTESTWD_PORT=8001 clean test 出现下图错误,帮忙看下如何处理,万分感谢🙏

yxys01 #21 · 2017年08月31日 作者
slideplustest 回复

你这个是代码层面的错误,建议去问@zhangzhao_lenovo;其次,我在https://testerhome.com/topics/9524#reply232xcode版本问题,你要不先降到8.3.3试试?看到你好像是

yxys01 回复

嗯,谢谢楼主回复,我正在下载8.3的,9的有点不靠谱~

yxys01 #23 · 2017年08月31日 作者
slideplustest 回复

希望你能成功运行。其实我也下了9来用过,确实兼容方面存在一定的问题,如果是研发还好,测试使用的框架有些地方不是那么友好。

请问楼上前辈下的Xcode8.3.3成功了吗?我也是执行到那一步报错了;错误原因如下图我看了一下Xcode版本是8.3.3,请教一下大神有什么办法能解决吗?

"xcode里中断运行时 有个log路径的日志输出 xxx/XCTestWD-xxx/Logs/Test/Attentment "
求问这个具体路径是?

bingle 回复

我找了很久才找到= =!
当前用户目录下的/Library/Developer/Xcode/DerivedData/XCTestWD-xxx/Logs/Test/Attachments

Test_Sir FastMonkey iOS11 踩坑记 中提及了此贴 10月11日 14:45

xcode 9.0,iOS 11 报错信息
/Users/Xx/Downloads/Fastmonkey-master/XCTestWD-master/XCTestWD/XCTestWDUITests/server/models/XCTestWDSession.swift:80:16: Use of unresolved identifier 'XCTestWDApplication'

fengcanfly 回复

解决方法:https://testerhome.com/topics/10390 这个帖子的问题2和问题3
#将XCTestWDApplication.m和XCTestWDApplication.m文件拖拽到Xcode中的PrivateHeaders文件下

需要在XCTestWDUITests-Bridging-Header.h文件中添加
#import "XCTestWDApplication.h"

30楼 已删除
slideplustest 回复

问题解决了,👍

_Aaron 回复

你的问题解决了么,我也遇到了同样的问题。

ode Signing Error: No profiles for 'XCTestWD.XCTestWDUITests' were found: Xcode couldn't find any iOS App Development provisioning profiles matching 'XCTestWD.XCTestWDUITests'. Automatic signing is disabled and unable to generate a profile. To enable automatic signing, pass -allowProvisioningUpdates to xcodebuild.

求助,一直报这个错误

The app ID "XCTestWD.XCTestWD" cannot be registered to your development team. Change your bundle identifier to a unique string to try again.

slideplustest 回复


我有这个文件了怎么还提示找不到呢。谢谢~

lrw3716740 回复

XCode设置里把XCTestWD->Build Setting->Header Search Paths和XCTestWD->Build Setting->Objective-C Bridging Header的值XCTestWD/XCTestWD-Bridging-Header.h删掉

slideplustest 回复


我已经删除了的,之前就是看的教程做的,谢谢~

pacerron 回复

这个错误怎么解决的?

jira 回复

这个我参考了ios签名与证书解决了,办法是改掉XCTestWD,XCTestWDUITests这两个target的Bundle Identifier, 随便在XCTestWD.XCTestWD后面加个字符串,如XCTestWD.XCTestWD.exter 就可以通过build了,我在xcode 9.2成功的

40楼 已删除
41楼 已删除

求助,我是刚接触的菜鸟,根据教程一步步来,也出现了评论里很多人提到的问题,一一解决了,但现在build的时候出现了个新错误:Failed to read file or folder at /Users/mac/Desktop/daisy/Fastmonkey-master/XCTestWD-master/XCTestWD/../Carthage/Build/iOS/Swifter.framework
Command /bin/sh failed with exit code 1
不知道怎么解决,我的carthage已经是29版本,且也update了

另:这个问题没有解决的前提下我执行xcodebuild那段代码时提示找不到设备(用的ipone x)求大神帮忙

lrw3716740 回复

我也出现过这个问题,文件都在还是提示这个错误,开发帮忙的解决办法是把bridging-Header.h这个文件中报错这句修改为下面这句(原来的注释了),我的问题解决了,希望能帮到你

45楼 已删除
jack_chen 回复

请问下,你的这个问题解决了吗?我这边按照教程操作时,也出现了这个问题。

Ld /Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Products/Debug-iphoneos/XCTestWD.app/XCTestWD normal arm64
cd /Users/didi/Fastmonkey/XCTestWD-master/XCTestWD
export IPHONEOS_DEPLOYMENT_TARGET=9.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Users/didi/.rvm/gems/ruby-2.1.10/bin:/Users/didi/.rvm/gems/ruby-2.1.10@global/bin:/Users/didi/.rvm/rubies/ruby-2.1.10/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin:/Users/didi/Library/Android/sdk/tools:/Users/didi/Library/Android/sdk/platform-tools:/Users/didi/apache-jmeter-3.3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/didi/.rvm/bin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch arm64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.2.sdk -L/Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Products/Debug-iphoneos -F/Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Products/Debug-iphoneos -F/Users/didi/Fastmonkey/XCTestWD-master/XCTestWD/../Carthage/Build/iOS -filelist /Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Intermediates.noindex/XCTestWD.build/Debug-iphoneos/XCTestWD.build/Objects-normal/arm64/XCTestWD.LinkFileList -Xlinker -rpath -Xlinker @executable_path/Frameworks -miphoneos-version-min=9.0 -dead_strip -Xlinker -object_path_lto -Xlinker /Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Intermediates.noindex/XCTestWD.build/Debug-iphoneos/XCTestWD.build/Objects-normal/arm64/XCTestWD_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fembed-bitcode-marker -fobjc-link-runtime -L/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos -Xlinker -add_ast_path -Xlinker /Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Intermediates.noindex/XCTestWD.build/Debug-iphoneos/XCTestWD.build/Objects-normal/arm64/XCTestWD.swiftmodule -framework Swifter -Xlinker -dependency_info -Xlinker /Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Intermediates.noindex/XCTestWD.build/Debug-iphoneos/XCTestWD.build/Objects-normal/arm64/XCTestWD_dependency_info.dat -o /Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Products/Debug-iphoneos/XCTestWD.app/XCTestWD
ld: warning: directory not found for option '-F/Users/didi/Fastmonkey/XCTestWD-master/XCTestWD/../Carthage/Build/iOS'
ld: framework not found Swifter
clang: error: linker command failed with exit code 1 (use -v to see invocation)

2018-04-13 21:36:27.827 xcodebuild[87354:1368155] Error Domain=IDETestOperationsObserverErrorDomain Code=14 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/2w/tt1p_4td3yq9xlbl7c2t4jn00000gn/T/com.apple.dt.XCTest/IDETestRunSession-1ECEA01F-BB7D-45AD-9CCE-65A7921FDBCA/XCTestWDUITests-C45C2C09-797F-45C7-9E6B-D470986D8814/Session-XCTestWDUITests-2018-04-13_213626-XBYpp5.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/2w/tt1p_4td3yq9xlbl7c2t4jn00000gn/T/com.apple.dt.XCTest/IDETestRunSession-1ECEA01F-BB7D-45AD-9CCE-65A7921FDBCA/XCTestWDUITests-C45C2C09-797F-45C7-9E6B-D470986D8814/Session-XCTestWDUITests-2018-04-13_213626-XBYpp5.log}

Testing failed:
Linker command failed with exit code 1 (use -v to see invocation)
** TEST FAILED **

The following build commands failed:
Ld /Users/didi/Library/Developer/Xcode/DerivedData/XCTestWD-ehrzcglifdezddhbggaxxxevomay/Build/Products/Debug-iphoneos/XCTestWD.app/XCTestWD normal arm64
(1 failure)

我把serverMode改成true,然后在执行完monkey之后出现如下错误
)}, isUniversal: 0, isXcodeManaged: 0, platforms: {(
<0x7fa0515441c0:>>,
<0x7fa051539ef0:>>
)}, filePath: <0x7fa054141ad0: profiles>>
)}
hasInternalSupport: NO
isSupportedOS: YES
developerDiskMountError: (null)
(null)
bootArgs:
connected: yes
isWirelessEnabled: no
connectionType: direct
} (11.2.6 (15D100))
MDMCreateDeltaDirectory:1920 calling MDMDirectoryDiff with:
state->old_bundle: /var/folders/pm/cw2vmzgx4fgbr69h7zl9fx1w0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/bc0dfc406daf17d162760c73af6a35fc/1fd2561c180fc6838fa7565de169960e965e9ec3/XCTestWDUITests-Runner.app
state->new_bundle: /Users/dengjian/Library/Developer/Xcode/DerivedData/XCTestWD-fnuhsnwpyzwltgcbbdpzwgexyhef/Build/Products/Debug-iphoneos/XCTestWDUITests-Runner.app
state->dst_bundle: /var/folders/pm/cw2vmzgx4fgbr69h7zl9fx1w0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.MpJNkW/XCTestWDUITests-Runner.app_sparse.ipa/Payload//XCTestWDUITests-Runner.app, binaryDiff flag: FALSE
dst_ipa: /var/folders/pm/cw2vmzgx4fgbr69h7zl9fx1w0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.MpJNkW/XCTestWDUITests-Runner.app_sparse.ipa
MDMDirectoryDiff_block_invoke:1473 calling writeDictToFile with: /var/folders/pm/cw2vmzgx4fgbr69h7zl9fx1w0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.MpJNkW/XCTestWDUITests-Runner.app_sparse.ipa/ManifestCache.plist
writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/pm/cw2vmzgx4fgbr69h7zl9fx1w0000gp/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/XCTestWDUITests-Runner.app.MpJNkW/XCTestWDUITests-Runner.app_sparse.ipa/ManifestCache.plist
2018-04-16 15:51:17.282802+0800 XCTestWDUITests-Runner[1989:456280] +[CATransaction synchronize] called within transaction
2018-04-16 15:51:17.499111+0800 XCTestWDUITests-Runner[1989:456280] Running tests...
2018-04-16 15:51:18.797476+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[CAMLightingControl accessibilityLabel]
2018-04-16 15:51:18.797842+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[CAMLightingControl accessibilityValue]
2018-04-16 15:51:18.797943+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[CAMLightingControl accessibilityTraits]
2018-04-16 15:51:18.798116+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[CAMLightingControl isAccessibilityElement]
2018-04-16 15:51:18.798203+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[CAMLightingControl accessibilityIncrement]
2018-04-16 15:51:18.798277+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[CAMLightingControl accessibilityDecrement]
2018-04-16 15:51:18.798354+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding +[CAMLightingControl safeCategoryBaseClass]
2018-04-16 15:51:18.798614+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[PHAsset accessibilityLabel]
2018-04-16 15:51:18.798698+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[PHAsset accessibilityValue]
2018-04-16 15:51:18.798766+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[PHAsset accessibilityTraits]
2018-04-16 15:51:18.799456+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding -[PHAsset _accessibilitySavePhotoLabel:]
2018-04-16 15:51:18.799583+0800 XCTestWDUITests-Runner[1989:456280] [AXValidations] UIAccessibility Error adding +[PHAsset safeCategoryBaseClass]
2018-04-16 15:51:18.841197+0800 XCTestWDUITests-Runner[1989:456280] Continuing to run tests in the background with task ID 1

Restarting after unexpected exit or crash in XCTextWDRunner/testRunner(); summary will include totals from previous launches.

Test Suite 'Selected tests' started at 2018-04-16 15:51:19.698
Test Suite 'XCTestWDUITests.xctest' started at 2018-04-16 15:51:19.701
Test Suite 'XCTestWDUITests.xctest' failed at 2018-04-16 15:51:19.702.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.001) seconds
Test Suite 'Selected tests' failed at 2018-04-16 15:51:19.704.
Executed 1 test, with 1 failure (0 unexpected) in 0.000 (0.006) seconds
** TEST FAILED **

我也是按照教程一步一步执行的,执行xcodebuild -project XCTestWD.xcodeproj -scheme XCTestWDUITests -destination 'platform=iOS,name=xxxx' XCTESTWD_PORT=8001 clean test时,报这个错误
writeDictToFile:1278 ==== Successfully wrote Manifest cache to /var/folders/70/5c415qt51rj208bd5c9yzhb00000gn/C/com.apple.DeveloperTools/All/Xcode/EmbeddedAppDeltas/2721498488b81f02aeaee4cd772b0522/4095ab2a6884d5522e1c8761ff31914b1ace6ab0/ManifestCache.plist
2018-04-19 11:48:47.898173+0800 XCTestWDUITests-Runner[584:30646] +[CATransaction synchronize] called within transaction
2018-04-19 11:48:48.006727+0800 XCTestWDUITests-Runner[584:30646] Running tests...
2018-04-19 11:48:49.847647+0800 XCTestWDUITests-Runner[584:30646] Continuing to run tests in the background with task ID 1
Test Suite 'All tests' started at 2018-04-19 11:48:50.782
Test Suite 'XCTestWDUITests.xctest' started at 2018-04-19 11:48:50.784
Test Suite 'XCTextWDRunner' started at 2018-04-19 11:48:50.785
Test Case '-[XCTestWDUITests.XCTextWDRunner testRunner]' started.
t = 0.00s Start Test at 2018-04-19 11:48:50.787
t = 0.09s Set Up
t = 0.13s Open com.PandaTV.Live-iPhone
t = 0.18s Launch com.PandaTV.Live-iPhone
t = 0.28s Assertion Failure: XCTestWDMonkey.swift:22: Failed to launch com.PandaTV.Live-iPhone: 未能完成该操作。Application "com.PandaTV.Live-iPhone" is unknown to FrontBoard.
t = 0.33s Tear Down
Test Case '-[XCTestWDUITests.XCTextWDRunner testRunner]' failed (0.327 seconds).
Test Suite 'XCTextWDRunner' failed at 2018-04-19 11:48:51.115.
Executed 1 test, with 1 failure (0 unexpected) in 0.327 (0.330) seconds
Test Suite 'XCTestWDUITests.xctest' failed at 2018-04-19 11:48:51.116.
Executed 1 test, with 1 failure (0 unexpected) in 0.327 (0.332) seconds
Test Suite 'All tests' failed at 2018-04-19 11:48:51.118.
Executed 1 test, with 1 failure (0 unexpected) in 0.327 (0.336) seconds
** TEST FAILED **

xueying 回复

Failed to launch com.PandaTV.Live-iPhone 工程中貌似是运行熊猫直播的app,你把test文件中的bundleid改成自己的bundleid试试

不知道为什么swifter 只有改成1.4.0才能从github下载成功

51楼 已删除

还有github "cezheng/Fuzi" ~> 1.0.0

Requesting connecion to device handle == 30 (serial: 3850dd31d6b7c9972e3ed84563db3536d6aadfec), port 8001
Error connecting to device!

遇到了上面的错误,是按照大佬的流程走的,xcode9.3,

执行如下命令时,xcodebuild -project XCTestWD.xcodeproj \
-scheme XCTestWDUITests \
-destination 'platform=iOS,name=Na_iPhone' \
XCTESTWD_PORT=8001 \
clean test
出现:

使用serve模式,执行第二个命令行时报错

需要 登录 后方可回复, 如果你还没有账号请点击这里 注册