如果逻辑失败,如何停止单元测试的执行。下面是例子。如何在 XCTAssertEqual("Hello", "Hi", "Passed")
条件失败时停止执行。
func test_one()
{
XCTAssertEqual("Hello", "Hi", "Passed")
let b = "Good Morning!"
// code continues...
}
最佳答案
XCTestCase
有一个默认为 true 的变量 var continueAfterFailure: Bool
。
这意味着即使在测试失败后测试仍会继续运行
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 - XCTAssert 中断函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31841355/