Commit 44370bb
Fail loudly when preparing the emulator for a test fails
The beforeEach hook in testBuilder swallowed every error from prepareEmulatorForTest, so an emulator in a bad state surfaced later as an unrelated assertion failure somewhere else in the scenario. It now logs and rethrows.
Rethrowing on its own would have broken every scenario, because iOS "simctl terminate" exits non-zero when the app is not running, and the app is not running before the first test of a scenario. Verified on Xcode 26.6 / iOS 26.5: terminate reports "found nothing to terminate" identically whether the app was never installed or is merely idle, so the error text and the exit code cannot tell a missing app apart from a broken simulator. simctl appinfo, get_app_container and listapps do not help either, as they only report whether the app is installed, and their output is unchanged by the app running or not.
So IOSEmulatorManager.endRunningApplication now establishes the running state up front with "simctl spawn booted launchctl list", where a running app appears as UIKitApplication:<bundle id> with a live pid, and skips terminate when the app is not running. Everything else propagates.
Android needs no equivalent guard: "am force-stop" exits 0 whether or not the app is installed or running (verified against an emulator), and "pm clear" is already guarded by an existence check. Adding one there would only add an adb round-trip per test.
Verified end to end against a live simulator and emulator for the installed-but-idle, never-installed and actually-running cases.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>1 parent ad5bb01 commit 44370bb
2 files changed
Lines changed: 23 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
409 | 409 | | |
410 | 410 | | |
411 | 411 | | |
412 | | - | |
413 | | - | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
414 | 419 | | |
415 | 420 | | |
416 | 421 | | |
| |||
461 | 466 | | |
462 | 467 | | |
463 | 468 | | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
464 | 481 | | |
465 | 482 | | |
466 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
39 | 42 | | |
40 | 43 | | |
41 | 44 | | |
| |||
0 commit comments