Section 2

Grid Unit Test Activated

Let's go back to our enhanced Grid Unit Test and add some code that exercises all this stuff. We can activate the cells in the laser beam path and then check if the target cell is on.

Let's run our tests and see what happens.

No joy. There's an error. Looks like the problem is that the cell has a nil gridLocation. If you inspect the cell you will see it is a Blank Cell. I wonder if we forgot to ensure that the blank cells have their locations set when the initial grid is created? Here's the #initializeCells method on our Grid class.

Sure enough, the code that initializes the grid with blank cells does not use the method we wrote to add cells. It accesses the cells dictionary directly through the accessor. Here's the method we should have been using.

Fix the initialization method.

Close the debugger if it's still open. Let's rerun our unit tests.

Something is wrong. The tests never finish running. Type a Command-. (Command Period) to interrupt Squeak and see where we are hung up.

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels    stevewessels@me.com