XCTAssert 中断函数
XCTAssert break function
如果逻辑失败,如何停止单元测试的执行。下面是例子。 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
}
如果逻辑失败,如何停止单元测试的执行。下面是例子。 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
}