🌱 Is there a way to reset the app between tests in Swift XCTest UI

Source

I see a lot of answers to uninstall your app in setUp or tearDown of your test.

But you can easily uninstall your app before launching your tests by adding a run script phase in your test target.

To do so :

Select your application’s Xcode project Select your test target Select “Build Phases” Tap on ”+” and “New Run Script Phase” Then, replace the placeholder # Type a script or drag a script file from your workspace to insert its path. by the command :

xcrun simctl boot ${TARGET_DEVICE_IDENTIFIER}
xcrun simctl uninstall ${TARGET_DEVICE_IDENTIFIER} YOUR_APP_BUNDLE

This doesn’t happen after each test still searching for the best way to reset app after each individual ui test

Made by Brandon . If you find this project useful you can donate.