Subito-it / SBTUITestTunnelHost

Add Mac host tunnel to your XCTests

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Assertion in launchCommand

BorisLys opened this issue · comments

I have problem when use launchCommand.

import SBTUITestTunnelHost
import XCTest

class InstantReplay_iOSUITests: XCTestCase {
    
    var commandID: UUID!
    
    override func setUp() {
        // Put setup code here. This method is called before the invocation of each test method in the class.

        // In UI tests it is usually best to stop immediately when a failure occurs.
        continueAfterFailure = false
        
        // UI tests must launch the application that they test.
        let app = XCUIApplication()
        app.launch()

        commandID = host.launchCommand(
            "xcrun simctl io booted recordVideo --codec=h264 --mask=black --force /Users/Jeff/Desktop/test.mov"
        )
        
        _ = app.wait(for: .runningForeground, timeout: 5)
        
        _ = app.textFields.firstMatch.waitForExistence(timeout: 0.5)

        if let commandID = commandID {
            addTeardownBlock { [unowned self] in
                self.host.interruptCommand(with: commandID)
            }
        }
        else {
            print("No status!")
        }
    }

    func testExample() {
        let app = XCUIApplication()
            
        app.textFields.firstMatch.tap()
        
        let keyDelay = { return TimeInterval.random(in: 0...0.15) }

        "UITestExample@example.com".map(String.init).forEach {
            if ["@", "."].contains($0) {
                app.keys["more"].tap()
                XCTAssertTrue(app.keys[$0].waitForExistence(timeout: keyDelay()))
                app.keys[$0].tap()
                app.keys["more"].tap()
            }
            else if $0 == $0.uppercased(), !app.keys[$0].exists {
                app.buttons["shift"].tap()
                XCTAssertTrue(app.keys[$0].waitForExistence(timeout: keyDelay()))
                app.keys[$0].tap()
            }
            else {
                XCTAssertTrue(app.keys[$0].waitForExistence(timeout: keyDelay()))
                app.keys[$0].tap()
            }
        }
        
        app.buttons["Return"].tap()
        
        XCTAssertTrue(app.textFields.firstMatch.waitForExistence(timeout: 0.5))
    }
}

Error:
** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '[SBTUITestTunnelHost] Message sending failed for action launch' terminating with uncaught exception of type NSException
Screenshot 2021-08-03 at 11 07 36

You should be using executeCommand instead of launchCommand as per documentation

I rewrite the method and still get an assert
host.executeCommand("xcrun simctl io booted recordVideo --codec=h264 --mask=black --force /Users/user/Desktop/test.mov")
Screenshot 2021-08-04 at 07 38 16

Is the Mac host app running?

yes. If i code:
host.executeCommand("pwd") - it's work
But when i try use:
host.executeCommand("xcrun simctl io booted recordVideo --codec=h264 --mask=black --force /Users/user/Desktop/test.mov")
I get assert

Did you try?

host.executeCommand("/usr/bin/xcrun simctl io booted recordVideo --codec=h264 --mask=black --force /Users/user/Desktop/test.mov")

Yes and i have the same assert

You might need to debug this on both sides, run your tests and the server app in Xcode and try to understand what is going wrong.