I have a class teardown which is trying to remove the app, but it doesn't recognize app.terminate().
class DeviceSettingsUtilities : UITestUtilities {
func removeApp(productName:String){
print("in teardown")
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
XCUIApplication().terminate() // this does nothing
XCUIApplication(bundleIdentifier: "com.xxx.xxxx").terminate()//this does nothing too, but this works when called as an instance teardown
sleep(5)
springboard.activate()
let icon = springboard.icons.matching(identifier: productName).firstMatch
// icon.exists is false when called as a class teardown
// icon.exists is true when called as an instance teardown
if icon.exists {
let iconFrame = icon.frame
let springboardFrame = springboard.frame
icon.press(forDuration:1.3)
springboard.coordinate(withNormalizedOffset: CGVector(dx: ((iconFrame.minX + 3) / springboardFrame.maxX), dy:((iconFrame.minY + 3) / springboardFrame.maxY))).tap()
sleep(5)
springboard.buttons["Delete"].firstMatch.tap()
sleep(5)
}
XCUIApplication().terminate()
}
}
This is being called in the test case class teardown method as shown below
override class func tearDown() {
super.tearDown()
let deviceSettings = DeviceSettingsUtilities()
deviceSettings.removeApp(productName: ProductName.rawValue)
}
This just doesnt delete the app, But if i change class func tearDown() to func tearDown() , it deletes the app with no problem. Not sure what i am missing. Any suggestions ?