Closed AlfioEmanueleFresta closed 9 years ago
The assertion was incorrect. At the start of a game the player is always given three goals, which is the maximum number of goals a player can have simultaneously. Therefore, when the turn increments, the number of goals a player has should not increase!
I've rewritten the tests for this unit to make them more rigorous..
Reopening issue....
Most of the time the test passes, however now and again (as shown by the Travis log) it will fail with the following assertionError:
Player should still have maximum of three goals expected:<3> but was:<4> Expected :3 Actual :4
Obviously a player should never have four goals. I'll start looking into why this is happening, although help would be appreciated on this one - I don't have a clue atm!
The problem was caused by using .getSize() for the array of goals. This array also contains no longer active goals (i.e. goals that have been completed or have failed). In these tests, if the player is given a goal that must be completed in X turns, once X turns have passed and the goal has failed, the player will be given another goal. Therefore, the size of the array will become 4.
This has been fixed by refactoring the Player method to have a new method getNumberOfIncompleteGoals(), which should be used instead.
We have all tests passing except this one.