我有一个XCTest包,我可以使用simctl
在模拟器上运行xcode。我正在使用带有以下环境变量的iPhone 6 iOS 9.1模拟器:
export SIMCTL_CHILD_TestBundleLocation="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator/Tests.xctest"
export SIMCTL_CHILD_XCInjectBundle="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator/Tests.xctest"
export SIMCTL_CHILD_XCInjectBundleInto="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator/ios_app.app/ios_app"
export SIMCTL_CHILD_XCTestConfigurationFilePath="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator/Tests.xctest/Tests-7025D700-AA6C-4343-9C7A-92F9CC3A1C42.xctestconfiguration"
export SIMCTL_CHILD_DYLD_LIBRARY_PATH="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks"
export SIMCTL_CHILD_DYLD_FRAMEWORK_PATH="/Users/User/ios_app/DerivedData/primus/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks"
此时此应用程序已安装在模拟器上,模拟器正在运行,我运行:
xcrun simctl launch booted uk.co.company.ios.app -NSTreatUnknownArgumentsAsOpen NO -ApplePersistenceIgnoreState YES -XCTest All
应用程序启动,从模拟器日志中我可以看到XCTest包加载但测试不运行。我已经注销了它似乎停止的位置,并且有一个私有方法_checkForTestManager
,更具体地说是_checkManagerForDaemonStateAndConnectIfAvailable
。据我所知,XCTest试图连接到testmanagerd
,但失败了。所以我尝试使用以下方法在模拟器上启动testmanagerd
:
xcrun simctl spawn booted launchctl kickstart system/com.apple.testmanagerd
但这似乎对测试运行没有影响,但我确实在模拟器日志中看到了一些额外的输出:
testmanagerd[41610]: Received new test session connection (-[XCTestManager listener:shouldAcceptNewConnection:])
testmanagerd[41610]: Initial orientation 0
testmanagerd[41610]: Test session <__NSConcreteUUID 0x7fd2bb804a00> 7025D700-AA6C-4343-9C7A-92F9CC3A1C42 requested socket (-[XCTestSession _XCT_requestSocketForSessionIdentifier:reply:])
testmanagerd[41610]: Test session <__NSConcreteUUID 0x7fd2bb804a00> 7025D700-AA6C-4343-9C7A-92F9CC3A1C42 requested socket (__57-[XCTestManager requestSocketForSessionIdentifier:reply:]_block_invoke)
testmanagerd[41610]: -[XCTestManager _handleRequestForSessionWithIdentifier:]
但之后没有。与通过Xcode运行时相比:
testmanagerd[41309]: Test session <__NSConcreteUUID 0x7fd162b016a0> 64B7815C-A0A2-4213-9A5E-E0BB0139F35A requested socket (-[XCTestSession _XCT_requestSocketForSessionIdentifier:reply:])
testmanagerd[41309]: Test session <__NSConcreteUUID 0x7fd162b016a0> 64B7815C-A0A2-4213-9A5E-E0BB0139F35A requested socket (__57-[XCTestManager requestSocketForSessionIdentifier:reply:]_block_invoke)
testmanagerd[41309]: -[XCTestManager _handleRequestForSessionWithIdentifier:]
testmanagerd[41309]: Closing IDE connection before sending socket 8 to test host.
testmanagerd[41309]: -[XCIDESession closeIDEConnection:] sending barrier
testmanagerd[41309]: barrier flushed, closing DTXConnection to IDE, socket will not be closed
testmanagerd[41309]: Socket disconnected
testmanagerd[41309]: __33-[XCTestManager closeIDESession:]_block_invoke <XCIDESession: 0x7fd160514d80>
testmanagerd[41309]: Considering exiting, 1 test sessions, 0 sessions with identifiers, 0 unidentified sessions...
assertiond[39075]: assertion failed: 14F1021 13B137: assertiond + 12188 [93FFE0B6-5C27-387F-B32A-6EE378BBB22A]: 0x1
testmanagerd[41309]: Sending socket 8 to test host
testmanagerd[41309]: __33-[XCTestManager closeIDESession:]_block_invoke <XCIDESession: 0x7fd160514d80>
testmanagerd[41309]: Considering exiting, 1 test sessions, 0 sessions with identifiers, 0 unidentified sessions...
testmanagerd[41309]: IDE connected over socket 7 (__47-[XCTestManagerIDEServer initWithListenSocket:]_block_invoke)
testmanagerd[41309]: Created session with socket 7
testmanagerd[41309]: Handling a proxy request from the IDE
testmanagerd[41309]: -[XCIDESession _IDE_initiateControlSessionForTestProcessID:] 41398
testmanagerd[41309]: Set control session <XCIDESession: 0x7fd160716f60>
是否可以通过simctl以这种方式运行测试?