December 2018
Intermediate to advanced
414 pages
10h 19m
English
In all the tests of the previous example, we used only one assertion, but XCTest comes with several types of assertions. Let's have a look at the most important ones.
All the assertions are based on a fundamental one:
XCTAssert(expression: Bool)
This checks whether the expression is true, otherwise, it stops and makes the test fail. In theory, we could use only this one to cover all the possible types of tests, but the other assertions help the reader understand the semantics of the test and what the developer wanted to express. Hence, a good rule is to use the more specific assertion needed for the test we are currently writing.
Slightly more precise assertions are the Boolean assertions, which check whether a value is true or ...
Read now
Unlock full access