Grid Unit Test
Write a unit test to validate the initial conditions for a Grid. Again, create the new class GridTestCase as a subclass of TestCase and then add methods. Here's our first test method. We'll be adding more to this method later.
Let's run our unit tests (including the new one we just created) and see how things are going.
We have a failure in our new Grid test method. Click on the failed method in the test runner and a debugger opens up for us.
Click once on the debug button to open up the debugger call stack. The method #initializeCells seems to be where our problem lies. There it is. We forgot to send #numberOfRows to self and the algorithm tried to use the instance variable directly. We knew the variable could have been nil and it was.
Okay, that's easy enough of a mistake to fix. Here's the corrected #initializeCells method for Grid. You can fix it right in the debugger. Just close it when after you have saved the change and then re-run the unit tests.
Rerun and everything passes.