XCTAssertTrue does not stop the routine

Xcode does not complete the test procedure for failed statements. It's right? I don’t understand the reasons for this, and I would like him to behave as he would to assertcomplete the program. On the next test, it will print "still working." Is this intended?

- (void)testTest
{
    XCTAssertTrue(false, @"boo");
    NSLog(@"still running");
}

I don’t see how this would be useful, because often the subsequent code fails when the preconditions are not met:

- (void)testTwoVectors
{
    XCTAssertTrue(vec1.size() == vec2.size(), @"vector size mismatch");

    for (int i=0; i<vec1.size(); i++) {
        XCTAssertTrue(vec1[i] == vec2[i]);
    }
}
+4
source share
3 answers

You can change this behavior XCTAssert<XX>.
In the setup method, change the value self.continueAfterFailureto NO.

IMO, , ( , , ). , , , .

+4

, . , . ; ( ). , , , , .

( ), , - , . , ? , - , : , , , . - :

Executed 7 tests, with 2 failures (1 unexpected) in 0.045 (0.045) seconds

- XCTAssert. .

0

, , "", . , return .

, , , , , .

:

, , , :

- (void)testTwoVectors
{
    XCTAssertTrue(vec1.size() == vec2.size(), @"vector size mismatch");

    for (int i=0; i<vec1.size(); i++) {
        XCTAssertTrue(vec1[i] == vec2[i]);
    }
}

, , , , return, , , , , , , .

, , . , , , .

When viewing the test results, sometimes it’s nice to know all the sources of failure, and not just the first ones.

0
source

Source: https://habr.com/ru/post/1541885/


All Articles