13

如果逻辑失败,如何停止单元测试执行。下面是示例。XCTAssertEqual("Hello", "Hi", "Passed")条件失败时如何停止执行。

func test_one() 
{    
    XCTAssertEqual("Hello", "Hi", "Passed")    
    let b = "Good Morning!" 
    // code continues...
}
4

1 回答 1

37

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
}
于 2015-08-05T19:44:25.667 回答