我正在使用 xctest 框架快速编写 UI 测试用例。
我想根据测试用例通过或失败或跳过触发另一个任务(例如截屏或)。我当前的代码如下
import Foundation
import XCTest
class HomePageChromeUITests: XCTestCase {
var pathStr:String = ""
override func setUp() {
super.setUp()
continueAfterFailure = false
self.launchWithUserLoggedIn()
}
override func tearDown() {
super.tearDown()
}
func testHomePageChrome_10385() {
let app = XCUIApplication()
let backButton = app.buttons[AccessibilityIdentifiers.PageEditorBackButton]
let editButton = app.buttons[AccessibilityIdentifiers.PageEditorEditButton]
XCTAssertTrue(backButton.exists && backButton.frame.origin.x < editButton.frame.origin.x, "Back button does not exist.---10385")
XCTAssertTrue(!editButton.exists, "Edit button does not exist.---10385")
}
}
Run Code Online (Sandbox Code Playgroud)
我想在测试用例失败时触发一个方法,并在那里传递我的失败消息,即“10385”。
我怎样才能做到这一点。任何帮助,将不胜感激。