Optimizing code for testability
Now that the project has a test target, it's time to start adding some tests to it. Before you add tests, you should determine what to test. Take some time to look at the app and the code and try to think of things to test. Assume that the app is finished and that the trivia questions are loaded from a server.
Some of the things you might have thought of to test are the following:
- Making sure that we can display the data we load from the network
- Testing that selecting the correct answer triggers the expected code
- Testing that choosing a wrong answer triggers the expected code
- Ensuring that the first question is displayed after we show the last one
- Testing that the question index increments
If you came up with most of the tests on this list, good job. You've successfully identified a lot of good test cases. But how do you test these cases? The project has been made hard to test intentionally, but let&apos...