The family of board games known as Mancala has many rule variants from around the world. We're going to use Mancala to help us think about Test-Driven Development. For our purposes, we'll assume Mancala is played with these rules, using a layout and bin-numbering scheme like this:
In class Monday, we imagined that we were going to develop
the game logic (not the user interface) for a Mancala game, and we
discussed possible methods for a MancalaBoard
class.
The methods in our game will include:
The goal of the current assignment will be to generate a collection of test cases to explore the behavior of the as-yet-unwritten MancalaBoard class. To enable us to automate the testing process, we need a file format in which to store test cases. Here, by fiat of the professor, it is.
Each test case will take up a single line in a text file. (Here, "line" means all the text between consecutive newline characters. Word-wrap and window size in this or that text editor is irrelevant to this definition of line.) The line will start with a comma-delimited sequence of bin indexes, each one representing a single move. After the final move, the line will contain a semi-colon, followed by an error code from among these options:
The error code shown should be the one that applies to the first illegal move found in the list of moves. If more than one error code applies to the first illegal move, then whichever applicable error code appears earlier in the list above should be used. Of course, if all the moves are legal, then the error code should be "NoError".
Following the error code, the test case will have a second semi-colon, which should be followed by a comma-separated list of the fourteen integers representing the expected contents of bins 0-13 at the end of the test or just before the first illegal move is attempted (if there are any illegal moves).
Finally, each test case will include a third semi-colon followed by a (possibly empty) comment briefly describing the test case's purpose.
For example, this test case represents a single move by Player 1, distributing the stones from Bin #1 into Bins 2, 3, and 4:
Because this one-move sequence is legal assuming the board begins with 3 stones in each of the non-store bins, the integers following the second semi-colon represent the contents of the 14 bins after the move.
Here are a few more possible test cases:
By class time on Wednesday, please deliver to me via e-mail 12 test cases in the format described above.
After I have collected all the test cases and we have had more discussion
on Wednesday in class, I will ask you to implement enough of the MancalaBoard
class to enable you to run the test cases. Next week, we will meet in the lab
and try all of the test cases generated by the class (and perhaps a few by me)
to see if we can find bugs in your program.
With this plan in mind, try to create test cases that probe the boundaries of the problem. You are trying to trip up your own program as well as the programs of the other students with the goal of making everybody's program as robust as possible.