This is not possible because the tool loses connection with the application after it is completed.
If you create a UI Automation script from the command line, you can run the second script automation after the first closes the application, which then checks that everything is reset.
instruments \ -D [trace document] \ -t [instruments template] \ /path/to/Bundle.app \ -e UIARESULTSPATH [directory to store test output] \ -e UIASCRIPT reset_the_app.js instruments \ -D [trace document] \ -t [instruments template] \ /path/to/Bundle.app \ -e UIARESULTSPATH [directory to store test output] \ -e UIASCRIPT check_that_the_app_is_reset.js
So, instead of trying to get the same instance of tools to restart and reconnect to the application, just run two separate scripts, one of which executes your reset -and-abort, and the other, which checks the received status of the application.
Jonathan penn
source share