WWDC2016对xcuitest的改进

虽然使用fbsimctl可以多开模拟器,但你不能使用xcodebuild进行并行测试,你还是得使用fbsimctl提供的接口启动xctest。

如果你尝试直接安装TestRunner.app到手机上启动,可以响应/status,但你并不能启动一个/session。这是因为xctest Framework得通过XPC连接到testmanagerddeamon来执行启动APP点击查询控件等。

WWDC2016支持了test-without-building的特性。你首先用build-for-testing构建xctestrun文件,然后用test-without-building启动:

# 这一命令会在/tmp/derivedDataPath/Build/Products下生成一个xctestrun的文件
# 名字像:WDARunner_iphonesimulator10.2-x86_64.xctestrun
xcodebuild build-for-testing -project /path/to/WDA.xcodeproj -scheme WDARunner -destination 'platform=iOS Simulator,id=XXX' -derivedDataPath /tmp/derivedDataPath
xcodebuild test-without-building -destination 'platform=iOS Simulator,id=XXX' -derivedDataPath /tmp/derivedDataPath2 -xctestrun /path/to/WDARunner_iphonesimulator10.2-x86_64.xctestrun
WWDC2016对xcuitest的改进_第1张图片
分布式测试

因为苹果的用意就是分发test bundle来方便分布式测试,Build Once, Test Anywhere。所以这个xctestrun文件你可以随意修改。build-for-testing时会将参数写入到xctestrun文件(比如TestBundlePathTestHostPathUITargetAppPath等)。test-without-building会从xctestrun读取配置参数启动测试。
关于更多xctestrun的信息,你可以通过man xcodebuild.xctestrun来查询

你可能感兴趣的:(WWDC2016对xcuitest的改进)