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 on January 29, 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. We'll
wrap up that discussion Monday, but we know for sure that the methods 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 indices, each one representing a single move. After the final move, the line will contain a semi-colon, followed by the fourteen integers representing the expected contents of bins 0-13 after the sequence of moves is complete, assuming the sequence of moves is legal. If any of the proposed moves is illegal (including a move after the game is over), then the semi-colon will be followed by one of the following error codes:
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.
Finally, each test case will include a second 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 semi-colon represent the contents of the 14 bins after the move.
Here are a few more possible test cases:
By class time on Monday, please deliver to me via e-mail 20 test cases in the format described above.
After I have collected all the test cases and we have had more discussion
on Monday in class, I will ask you to implement enough of the MancalaBoard
class to enable you to run the test cases. On Friday, 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.