For this assessment you will write tests for a game of Othello (also known as Reversi). An example game is shown in Figure 1 below (ignore the numbers on the board for the moment): see image.
Figure 1: An example Othello board (source: http://www.britishothello.org.uk/rules.html).
Othello is a two-player game played with tokens on a grid. In the real game each token has a white side and a black side. One player plays the black side of the token and the other plays the white side. The aim of the game for each player is to fill the board with their own colour, or to at least have more of their colour showing than the other player. The game starts with the board in the following configuration (source: http://www.britishothello.org.uk/rules.html): see image.
Figure 2: The initial configuration of an Othello game showing the positions in which black may play (source: http://www.britishothello.org.uk/rules.html).
The player must attempt to turn a sequence of tokens to their own colour horizontally, vertically or diagonally. Black always plays first. The crosses on the image in Figure 2 show where black can play in this initial configuration. Black must seek to turn a sequence of tokens black by placing a token in such a position that black tokens 'flank' white tokens (i.e. there is a black token either side of one or more white tokens). The crosses in the image in Figure 2 show the positions where this would be true. If a black token is placed in any of those positions then all of the white tokens that are between the black tokens are flipped over to show black (with this initial configuration only one white token would be flipped). If the black token is placed in position 5F, for example, the grid would now look like this: see image.
Figure 3: The state of the board after black has played.
It is now white's turn to play. In which positions can the white token be placed given this configuration? Yes, in 6F, 6D and 4F (don't forget, the player can play diagonally too).
Returning to Figure 1, the numbers in the image show the positions in which white can play at that particular point in the game. As you can see, there are a lot of potential moves.
The game continues in this fashion until (a) one of the players has filled the board with their colour or (b) neither player can play a token. In case (a) the player who has filled the board wins; in case (b) the player with the most tokens of their colour wins.
There are online versions of the game that you can play to gain familiarity, for example http://www.othelloonline.org.
Your task is to write the test classes for this project. You will write test classes for the main game classes but not for the GUI. The test classes that you need to write are listed in this document.
You will write test classes using JUnit. Your aim is to achieve the highest coverage that you can. Your coverage needs to be 98% or above in all test classes.
Note that one of the classes you are testing OthelloModel has an error in it. It will allow illegal plays. You should try and find that using your tests.
1. Create a new eclipse project and add the source files you have received to it. Make sure you set the correct package name uk.ac.wlv.cs5006.othello.
2. Create a new package in your project called uk.ac.wlv.cs5006.othellotests. You will place your test classes in here.
3. Add your project to version control (in a NEW folder) and push it to the GitLab server.
3. Run the project and play the game to familiarise yourself with it. See if you can replicate the error in the OthelloModel class described above.
4. You need to read the Javadoc comments for each of the classes for which you need to write a test. You need to read them so you understand what the behaviour of each class is meant to be so that you can write test classes for them. You also need to read the test specifications since that tells you what you need to test too.
You can read the Javadoc comments directly in the source code or you can generate the Javadoc html from eclipse, and then read that (Menu: Project->Generate Javadoc ). Make sure you understand what each method is designed to do because you will need to write tests to check that behaviour.
5. For each of the test classes you need to write, add a new test class and then add whichever methods to that you feel necessary to test the behaviour of the class. Each test class must be named classNameTest. For example, if you are testing a class called Grid your test class must be called GridTest.
6. You must check the coverage of your tests with the eclipse plug in called eclemma. This is actually integrated into the development environment so is available from the menus. See the additional guidance notes on WOLF on this, or the user guide on the eclemma website: http://www.eclemma.org/userdoc/index.html .