XCTAssert break函数

Cod*_*der 9 unit-testing ios xctest swift xctestexpectation

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

func test_one() 
{    
    XCTAssertEqual("Hello", "Hi", "Passed")    
    let b = "Good Morning!" 
    // code continues...
}
Run Code Online (Sandbox Code Playgroud)

Kev*_*vin 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
}
Run Code Online (Sandbox Code Playgroud)