Reporting a single test result
So far, our single test just prints its hardcoded name when run. There was some early thinking that we might need a result in addition to the test name. This is actually a good example of adding something to the code that is not needed or used. Okay, a minor example because we will need something to keep track of whether the test passes or fails, but it’s still a good example of getting ahead of ourselves because we have actually never used the mResult
data member yet. We’re going to fix that now with a better way to track the result of running a test.
We’ll assume that a test succeeds unless something happens to cause it to fail. What can happen? There will eventually be a lot of ways you can cause a test to fail. For now, we’ll just consider exceptions. This could be an exception that a test throws on purpose when it detects something is wrong or it could be an unexpected exception that gets thrown.
We don’t...