XCUITest Class teardown isnt deleting the app. But works if its instance teardown. What am I doing wrong?

前端 未结 3 1405
野的像风
野的像风 2021-01-27 19:29

I have a class teardown which is trying to remove the app, but it doesn\'t recognize app.terminate().

class DeviceSettingsUtilities : UITestUtilities {
func remo         


        
3条回答
  •  [愿得一人]
    2021-01-27 20:17

    I'm using the below workaround to terminate the app after last test case of a class.

    class BaseClass: XCTestCase {
    
            static var LastTestCaseName: String = ""
    
            override class func setUp() {
                LastTestCaseName = defaultTestSuite.tests.last!.name
                super.setUp()
            }
    
            override func tearDown() {
                let app = XCUIApplication()
                if BaseClass.LastTestCaseName == testRun?.test.name {
                    app.terminate()
                }
            }
        }
    

提交回复
热议问题