Skip to content

Commit

Permalink
Improvements to E2E tests fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert committed Jan 18, 2024
1 parent 5429784 commit 177b76a
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions features/fixtures/ios/Fixture/Fixture.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ class Fixture: NSObject, CommandReceiver {

func receiveCommand(command: MazeRunnerCommand) {
readyToReceiveCommand = false

var isReady = true
DispatchQueue.main.async {
logInfo("Executing command [\(command.action)] with args \(command.args)")
switch command.action {
case "run_scenario":
self.runScenario(scenarioName: command.args[0])
self.runScenario(scenarioName: command.args[0], completion: {
self.readyToReceiveCommand = true
})
isReady = false;
break
case "invoke_method":
self.invokeMethod(methodName: command.args[0], args: Array(command.args[1...]))
Expand All @@ -56,11 +59,13 @@ class Fixture: NSObject, CommandReceiver {
default:
assertionFailure("\(command.action): Unknown command")
}
self.readyToReceiveCommand = true
if isReady {
self.readyToReceiveCommand = true
}
}
}

private func runScenario(scenarioName: String) {
private func runScenario(scenarioName: String, completion: @escaping () -> ()) {
logInfo("========== Running scenario \(scenarioName) ==========")
let scenarioClass: AnyClass = NSClassFromString("Fixture.\(scenarioName)")!
logInfo("Loaded scenario class: \(scenarioClass)")
Expand All @@ -74,9 +79,12 @@ class Fixture: NSObject, CommandReceiver {
logInfo("Starting scenario in class \(scenarioClass)")
scenario!.run()
logInfo("========== Completed scenario \(scenarioName) ==========")
Thread.sleep(forTimeInterval: 2.0)
scenario!.reportMeasurements()
Thread.sleep(forTimeInterval: 1.0)
DispatchQueue.main.asyncAfter(deadline: .now() + 2.0) {
self.scenario!.reportMeasurements()
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
completion()
}
}
}

private func invokeMethod(methodName: String, args: Array<String>) {
Expand Down

0 comments on commit 177b76a

Please sign in to comment.