The first test
Now that the project is compilable, let's move to the test file, called something similar to RpnCalculatorTests. As you can see, Xcode already implemented a few tests using a template; however we don't need any of those, so we delete all the template code and start from scratch. The first test we want to write is to check that when we insert the number 2, we have that number in the line0 property of the model. An important piece of information to know when using XCTest is that all the tests must start with the test prefix; this is the way Xcode understands how to run the tests – using inspection it searches for all the functions in a subclass of XCTestCase whose names start with test. Apart from that, we are free to call the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access