如果逻辑失败,如何停止单元测试执行。以下是示例。如何在XCTAssertEqual("Hello", "Hi", "Passed")
条件失败时停止执行。
func test_one()
{
XCTAssertEqual("Hello", "Hi", "Passed")
let b = "Good Morning!"
// code continues...
}
答案 0 :(得分:28)
XCTestCase
有一个变量var continueAfterFailure: Bool
,默认为true。
这意味着即使在测试失败后测试仍继续运行
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
continueAfterFailure = false
}