| Test Number | Reason Tested | Method / Data Used | Expected Result | Actual Result | Correct |
|---|---|---|---|---|---|
Food |
|||||
| 1.1 | Test if can create a Food Object | - | Food object created and assigned a type | Food object created and assigned the type "Junk" | Yes |
| 1.2 | Test if food is selected at right probability | Create 1000 Food objects and total up their frequencies |
Nutritious ~ 31% Junk ~ 63% Poison ~ 6% Other = 0% |
Nutritious: 31.5% Junk: 62.6% Poison: 5.8999999999999995% Other: 0.0% |
Yes |
Creature |
|||||
| 2.1 | Test if can create a Creature Object | - | Creature object created with a blank name, a status of 0 (Hungry), Age set to 0 and Max Age set to 25. |
Name: Status: 0 Age: 0 MaxAge: 25 |
Yes |
| 2.2 | Test if can create a Creature Object with a name | Create a Creature with the name of "Eddy" | Creature object created with a name of "Eddy", a status of 0 (Hungry), Age set to 0 and Max Age set to 25. |
Name: Eddy Status: 0 Age: 0 MaxAge: 25 |
Yes |
| 2.3 | Truncates a long name to 20 Characters | Create a Creature with the name of Name: "This name has to be over twenty characters" | Name truncated |
Name: "This name has to be " Length: 20 |
Yes |
| 2.4 | Test what happens if a Null String is passed in as a name | - | A CreatureException is thrown | Exception is thrown | Yes |
| 2.5 | Test if can set Max Age through setMaxAge(int age) method |
Create a creature. Set Max Age to 50 |
Max Age is set to 50 | MaxAge: 50 | Yes |
| 2.6 | Test result if Max Age is set to 0 or less |
Create a creature. Set Max Age to 0 |
A CreatureException is thrown | Exception is thrown | Yes |
| 2.7 | Tests to see if a Creature Ages and dies when it gets too old |
Create a creature. Run dayPassedNoFood() method |
Creature ages advances until its 25 and then dies. | Creature age = 25 and status is 3 (Dead) | Yes |
| 2.8 | Test result of Creatures eating different types of food |
Create four Creatures. Feed three creatures a different food each. Let the fourth one go without food |
|
As expected | Yes |
| 2.9 | Test what happens if a Food of Null reference is passed to Creature's dayPassed() method |
Create a Creature. Pass Food with a Null reference to the method dayPassed() |
A CreatureException is thrown | Exception is thrown | Yes |
Plot |
|||||
| 3.1 | Test if can create a Plot Object | - | Plot is created | Plot is created | Yes |
| 3.2 | Test if can create a Plot object with a name | Name = "Canada" | Plot is created with the name "Canada" | Plot is Created with the name "Canada" | Yes |
| 3.3 | Test what happens if a Null reference is passed in for a name | - | A PlotException is thrown | A Exception is thrown | Yes |
| 3.4 | Test if can add a Creature to the Plot |
Create a Plot. Add a Creature with the name "New Creature" to the Plot |
Creature is successfully added. | Creature is successfully added. | Yes |
| 3.5 | Test if there cannot be more than two Creatures in the Plot at once. |
Create a Plot and three Creatures. See if it's possible to add all three to the plot. |
A PlotException is thrown. | A Exception is thrown | Yes |
| 3.6 | Test what happens if a Creature with a Null reference is passed |
Create a Plot. Pass a Creature with a Null reference to addCreature() method |
A PlotException is thrown. | A Exception is thrown | Yes |
| 3.7 | Test if it rains in a random fashion |
Create a Plot. Run the method simulateRain() 1000 times and collect the frequencies if it rained or not. |
Rained ~ 50% Not Rained ~ 50% |
Rained: 52.8% Not Rained: 47.2% |
Yes |
| 3.8 | Test to see if Food is grown in a plot and the count of Food cannot exceed 3 |
Create a Plot. Run the method simulateRain() 100 times. See if the Plot only contains three pieces of Food |
There are only three pieces of Food | As Expected | Yes |
| 3.9 | Test to see if isPlotEmpty() and isPlotFull() methods work correctly | - |
When the Plot is empty: isPlotEmpty() = true isPlotFull() = false When Plot has one Creature: isPlotEmpty() = false isPlotFull() = false When Plot has two Creatures: isPlotEmpty() = false isPlotFull() = true |
isPlotEmpty(): true isPlotFull(): false isPlotEmpty(): false isPlotFull(): false isPlotEmpty(): false isPlotFull(): true |
Yes |
| 3.10 | Test to see if getCreatureCount() method works. |
Run getCreatureCount() without any Creatures in the Plot. Add a Creature and run getCreatureCount() again. Add another Creature (total of 2) and run getCreatureCount() again. |
Correct count of Creatures is returned. |
Creature Count: 0 Creature Count: 1 Creature Count: 2 |
Yes |
| 3.11 | Test to see if getCreature(int index) method works. |
Create a Plot and add two Creatures to it. Run getCreature(0) and getCreature(1) and see if the correct Creatures are returned |
Correct Creatures are returned. |
First Creature place: First Creature Second Creature place: Second Creature |
Yes |
| 3.12 | Test an "Out of boundary Index" for the method getCreature(int index). |
Create a Plot and add two Creatures to it. Run getCreature(-1) and getCreature(3) and see what happens. |
A PlotException is thrown |
assignmentone.PlotException: Index for getCreature is out of bounds assignmentone.PlotException: Index for getCreature is out of bounds |
Yes |
| 3.13 | Test to see if getFoodCount() method works. |
Create a Plot. Run getFoodCount() method. Loop the method simulateRain() a hundred times. Run getFoodCount() method. |
Program returns 0 and then 3. |
First Run: 0 After 100 Loops: 3 |
Yes |
| 3.14 | Test to see if getFood(int index) method works. |
Create a Plot and run simulateRain() method a hundred times. Run getFood(0), getFood(1) and getFood(2) and see if Food is returned. |
Food is returned. |
First Food Slot: Poison Second Food Slot: Junk Third Food Slot: Junk |
Yes |
| 3.15 | Test an "Out of boundary Index" for the method getFood(int index). |
Create a Plot. Run getFood(0) right away. Run simulateRain() method a hundred times. Run getFood(-1) and getFood(3) and see what happens. |
PlotExceptions are thrown. |
assignmentone.PlotException: Index for getFood is out of bounds assignmentone.PlotException: Index for getFood is out of bounds assignmentone.PlotException: Index for getFood is out of bounds |
Yes |
| 3.16 | Test if a Hungry Creature can be 'popped' from the Plot |
Create a Plot. Add a Hungry Creature and immediately try and pop it |
The creature gets popped and removed from the plot | As Expected | Yes |
Land - Part OneI broken up testing the Land in two parts. The first part is basically testing if the Land object can be created. I'll test more about Plot, Creature and Food action in the Land after I have tested the GUI |
|||||
| 4.1 | Test if can create a Land Object | - | A Land Object is created with 15 Plots and 15 Creatures. |
Number of Plots: 15 Number of Creatures: 15 |
Yes |
| 4.2 | Test to see the results if an invalid number of Creatures is passed to the constructor of Land | Number of Creatures = 10 | A Land Object is created with 15 Plots and 10 Creatures. |
Number of Plots: 15 Number of Creatures: 11 |
No Fixed |
| 4.3 | Test if can create a Land Object with a specific number of Creatures | Number of Creatures = 16 | An IllegalArgumentException is thrown | An Exception is thrown | Yes |
Run and MainCanvas |
|||||
| 5.1 | Test if the Application starts up and displays correctly | - | Application starts up and displays correctly | As Expected | Yes |
| 5.2 | Test if the Exit button works | - | Application quits | As Expected | Yes |
| 5.3 | Test if the Simulate a Day button works | - |
Application calls simulateDay() method in the world object. MainCanvas is repainted to reflect new changes. |
As Expected | Yes |
| 5.4 | Test if the AutoRun button works | - |
|
As Expected | Yes |
| 5.5 | Test if the Display Aged checkbox works | - | Age and Max Age is toggled over the Creatures in the Plots. | As Expected | Yes |
| 5.6 | Test if the Land is drawn correctly | - |
|
Plots drawn correctly. Graveyard is drawn correctly but moves some buttons in the program in an unexpected fashion when the first Creature dies. |
No (To be fixed) |
| 5.7 | Test if the Plots are drawn correctly | - |
|
As Expected. | Yes |
| 5.8 | Test if the Reset button works | - |
|
As Expected. | Yes |
Land - Part Two |
|||||
| 6.1 | Test to see that Creatures start up in their own Plots. No Plot starts with two Creatures in it. | - | Only one Creature in a Plot at startup. | As Expected. | Yes |
| 6.2 | Test to see if Day attribute increase as days go by in the simulation. | Press Simulate a Day button 10 times | Day will equal 10. | As Expected. | Yes |
| 6.3 | Test that Creatures get assigned a unique name at startup. |
Start Simulation and observe the Creature names. Restart the Simulation but remove the names.txt file so the program is forced to create random names. |
Both times each Creature has a unique name at startup. | As Expected. | Yes |
| 6.4 | Creatures move in a random fashion when hungry to a Plot with food. | - |
Creatures move to different Plots with Food when Hungry. Two hungry Creatures on the same PLot will not always follow each other. |
As Expected. | Yes |