Reset iOS simulator between tests

I have a set of automated test cases created in tools that use tuneup.js to test an application. I decided to use tuneup.js, because it allowed me to separate my tests in separate test cases and run the entire set from one individual script, this works fine if all the tests run fine, however if one of them fails, all the tests fail because the simulator remains in an unknown state (I wrote my tests so that they all start and end on the same login screen) Is there a way to reset the simulator or restart the application between test cases?

+6
source share
3 answers

Try running tests from the command line. Automation of the user interface allows you to perform only one test in one run. After the test is completed (it does not matter if it was failed or passed), the application will be knocked out by the system (UIAutomation). At least it works with real devices.

Running the command line script will work as follows: 1. Reads the configuration file (it can be any txt or xml file) with the path to your tests. At this point, you will have an array with a path to your tests and the total number of tests. 2. Then, using a simple "for" loop (from 1 to "testcount"), it will start UIAutomation with the required parameters. One of the parameters will be the path to your test script, which was read from the configuration file.

You can also put the path to the "configuration file" as a parameter to run the command line script. This will allow you to run any test suite by simply invoking a script to run with the necessary configuration file.

0
source

I wrote a script that will reset the contents and settings of all versions and devices for iOS Simulator. It captures device names and version numbers from the menu, so it will include any new devices or iOS versions that Apple releases for simulators.

Easy to start manually or used in build-script. I would suggest adding it as a preliminary script action before building.

https://github.com/michaelpatzer/ResetAllSimulators

0
source

After unsuccessful tests, your application in an unknown state is one of the main problems with using Apple tooling as it is. We solved this in a framework called Porthole (on GitHub and inspired by tuneup.js) in two ways.

First, we wrote an automation bridge - a channel for RPC with the application under test, which allows us to reset our application before each test.

In cases where this is not enough, the porthole test runner has the ability to re-run each failed test in its own initial run of the simulator (for example, with --retest 1x,solo ).

0
source

Source: https://habr.com/ru/post/916922/


All Articles