Assert

The final A in the 3-As approach is assert. During the assert step, you make sure that the state of the object you're testing is as you'd expect. Act and assert can be used multiple times in a single test. For instance, you might want to assert that doing something once places the object in a particular state and that doing it again places the object in another state. Or possibly that the state stays the same. Just as with the other two steps, if you're asserting a lot of things, or if you're acting and asserting over and over again in a test, the chances are that your test is too broad. This can't always be avoided, but long tests with a lot of acting and asserting are often an indication of testing too much at once.

Reading about testing can be quite dull, and it tends to get abstract quickly, so let's leave the theory for now. You will set up a test suite for an existing project in Xcode and start writing some tests, so all of the information you've taken in so far becomes a bit more tangible.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset