【发布时间】:2016-04-22 19:15:42
【问题描述】:
我有一个在每次tearDown() 期间都会调用的注销函数,但以这种方式调用时不起作用。如果我在测试期间调用相同的注销功能,它工作正常。我想知道在拆解期间 XCUI 测试的行为是什么,有限制吗?我尝试使用 lldb 调试和调用 app.swipeRight() (espression->write code)...
-------
Navbar.swift
-------
import XCTest
import Foundation
class NavbarTest: XCTestCaseLib{
override func setUp()
{
super.setUp()
continueAfterFailure = false
}
override func tearDown()
{
logout()
super.tearDown()
}
func testSideBar_STAGING(){
//...<test code that executes no problem>
//...
}
}
-----
XCTestCaseLib.swift
------
import XCTest
import Foundation
class XCTestCaseLib: XCTestCase {
let app = XCUIApplication()
func logout() {
app.swipeRight()
...
}
【问题讨论】:
-
您确定
tearDown()函数正在执行吗?在那里添加一个日志语句以确保。另外,如果您调用self.logout()而不是logout(),行为会改变吗?
标签: swift xctest xcode-ui-testing xctestcase