Search code examples
iosios-ui-automation

Preventing iOS Automation Instruments from automatically retrying the test after failure


When my test runs into a critical failure such as tapping an invalid element the Automation Instrument attempts to restart the test from the beginning which results in a lot of errors and can even lag my system, making it difficult to stop the test. I don't have the repeat option enabled. Is there a way of preventing this behavior?


Solution

  • I reckon what you can do is: try capturing when your test runs into a failure by means of a try/catch block.

    When your test fails, it will jump inside the catch block and you can stop it there.

    Maybe something like this.

    try {
      // Run your tests
    } catch (exception){
      UIALogger.logFail("Test failed with error message: " + exception.message);
    }
    

    I think that the logFail() method should be enough to keep your tests from running indefinately.