swiftuiswift5xctestxctestcase

I can't delete my application during the teardown phase of my tests


I'm writing tests within my SwiftUI application and am working with XCTest and XCTestCase. Within my tests, I'm working with (and without) certain user permissions.

The problem that I am running into, is that once permission is set, I must delete the app or reset the settings of the simulator.

I'd like to automate this process within the tests themselves. I was referencing Is there a way to reset the app between tests in Swift XCTest UI?, but the solutions are written in Swift 4 and Swift 3, whereas I am working with Swift 5.

I've also tried XCUITest Class teardown isnt deleting the app. But works if its instance teardown. What am I doing wrong? and can't seem to get that working either.


Solution

  • You can reset application's permissions with Xcode 11.4 API https://developer.apple.com/documentation/xctest/xcuiapplication/3526066-resetauthorizationstatus


    If you still want to delete the app on iOS 13, check my answer here How to delete/reset an app from iOS 13 with XCTest?