Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCTAssert break function

How to stop unit test execution if a logic is failed. Below is the example. How to stop execution when XCTAssertEqual("Hello", "Hi", "Passed") condition is failed.

func test_one() 
{    
    XCTAssertEqual("Hello", "Hi", "Passed")    
    let b = "Good Morning!" 
    // code continues...
}
like image 1000
Coder Avatar asked Aug 05 '15 19:08

Coder


1 Answers

XCTestCase has a variable var continueAfterFailure: Bool which defaults to true. This means that the test continues running even after a test fails

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
}
like image 127
Kevin Avatar answered Oct 10 '22 02:10

Kevin