Skip to content
本页目录

广告 ADS

XCTest相关

本文介绍如何发起XCTest。

启动 WebDriverAgent Server

输入指令

bash
sib run wda

即可简单启动 WebDriverAgent!可以浏览器访问 http://localhost:8100/status 查看wda状态。


一般地,我们的bundleId都是自定义的, 这时候可以加上 -b--bundleId 选项指定,如果不包含 .xctrunner 会自动补全。

输入指令

bash
sib run wda -b org.cloud.sonic.WebDriverAgentRunner

如果我们需要自定义wda的启动port和转发port,我们可以加上 --server-local-port 选项和 --server-remote-port 来指定.

输入指令

bash
sib run wda -b org.cloud.sonic.WebDriverAgentRunner --server-local-port=8101 --server-remote-port=8200

可以浏览器访问 http://localhost:8200/status 查看wda状态。


类似地,mjpeg-server的配置也是如此。

输入指令

bash
sib run wda -b org.cloud.sonic.WebDriverAgentRunner --mjpeg-local-port=8101 --mjpeg-remote-port=8200

可用选项

快捷使用选项名数据类型描述信息
-b--bundleIdstringWebDriverAgent的包名(支持模糊匹配)
--disable-mjpeg-proxy不转发mjpeg-server服务端口
--disable-show-log不打印WebDriverAgentRunner服务的日志
--mjpeg-local-portintmjpeg-server本地启动端口
--mjpeg-remote-portintmjpeg-server转发端口
--server-local-portintWebDriverAgentRunner本地启动端口
--server-remote-portintWebDriverAgentRunner转发端口
-u--udidstring指定目标udid设备,不指定默认获取列表第一个设备
-h--help获取帮助指南

其他XCTest

输入指令

bash
sib run xctest -b your.app.bundleId

一般地,我们会启动时带上多个参数 输入指令

bash
sib run xctest -b your.app.bundleId -e TEST_ENV_1=hello -e TEST_ENV_2=world

运行fastbot示例

注意

因为wda与fastbot底层有共同部分,所以两个框架进程可能会有互相阻塞或冲突。因此wda与fastbot不建议同时运行。

bash
sib run xctest -b fastbot的bundleId -e BUNDLEID=被测应用的bundleId -e duration=测试时长 -e throttle=300

可用选项

快捷使用选项名数据类型描述信息
-b--bundleIdstring测试包的包名(支持模糊匹配)
-e--env[]string附带参数
-u--udidstring指定目标udid设备,不指定默认获取列表第一个设备
-h--help获取帮助指南

本文贡献者