を使用してシミュレーターで xcode を実行できる XCTest バンドルがありsimctl
ます。次の環境変数で 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 を介してテストを実行することは可能ですか?