Run XCTest bundle with simctl

蓝咒 提交于 2019-12-05 22:16:14

问题


I have a XCTest bundle which I can run through xcode on a simulator by using simctl. I am using the iPhone 6 iOS 9.1 simulator with the following environment variables:

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"

The app is already installed on the simulator by this point and the simulator is running and I run:

xcrun simctl launch booted uk.co.company.ios.app -NSTreatUnknownArgumentsAsOpen NO -ApplePersistenceIgnoreState YES -XCTest All 

The app launches and from the simulator log I can see that the XCTest bundle loads but the tests don't run. I have logged out where it seems to stop and there is a private method _checkForTestManager, more specifically _checkManagerForDaemonStateAndConnectIfAvailable. From what I can tell XCTest is trying to connect to testmanagerd but failing. So I tried kickstarting testmanagerd on the simulator using:

xcrun simctl spawn booted launchctl kickstart system/com.apple.testmanagerd 

But this doesn't seem to have an effect on the tests running, but I do see some additional output in the simulator log:

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:]

But nothing after that. Compared with when running through 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>

Is it possible to run tests through simctl this way?

来源:https://stackoverflow.com/questions/33633882/run-xctest-bundle-with-simctl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!