ios – XCTAssert中断功能

前端之家收集整理的这篇文章主要介绍了ios – XCTAssert中断功能前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如果逻辑失败,如何停止单元测试执行.以下是示例.如何在XCTAssertEqual(“Hello”,“Hi”,“Passed”)条件失败时停止执行.
func test_one() 
{    
    XCTAssertEqual("Hello","Hi","Passed")    
    let b = "Good Morning!" 
    // code continues...
}

解决方法

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
}

猜你在找的iOS相关文章