Skip to content

Testing

meihapps edited this page May 2, 2024 · 2 revisions

Unfortunately, there was not a whole lot of unit testing we could do with our project as a result of the large amount of impure functions, heavy usage of ui and occasional use of random number generation throughout the codebase, however we did manage to find a function that could unit test well.

The next turn function on the TurnTracker Queue was fully pure and deterministic, unfortunately the function is very simple so testing it did not yield any interesting or notable results.

Inputs

Instantiate a TurnTracker object with players and call next turn until a cycle is completed.

Expected Outputs

Current player should cycle through the queue and wraparound back to the start.

Actual outputs

As expected.

Pass/Fail

Pass.


There were a lot of other functions that were still tested however, even if less vigorously than a unit test. For example:

Inputs

We pitted 5 AI players against one another and watched the gameplay to ensure the AI was behaving as expected.

Expected outputs

All functionality is roughly as expected (with some element of randomness due to the nature of the AI)

Actual outputs

Barely ever making a reasonable move at all, seemingly picking moves entirely at random.

Pass/Fail

Fail

Actions

After looking into this deeper, it turns out the wrong function was being used to decide whether to randomly do a bad move or not and instead of getting the normal X% chance that a bad move occurs, it was always picking a bad move. We rectified this by replacing the random number generating function with the correct one.


Inputs

We pitted 5 AI players against one another AGAIN and watched the gameplay to ensure the AI was behaving as expected with the altered code

Expected outputs

All functionality is roughly as expected (with some element of randomness due to the nature of the AI)

Actual outputs

Moves seem mostly reasonable, however troops being placed badly is much more common than expected.

Pass/Fail

Fail

Actions

Make the AIs have no chance of picking a bad move temporarily to investigate further.


Inputs

We pitted 5 AI players against one another AGAIN and watched the gameplay to ensure the AI was behaving as expected with the altered code and no chance of a bad move

Expected outputs

The placement of troops should be improved

Actual outputs

Placement of troops still remained erratic and poor

Pass/Fail

Fail

Actions

Will need further investigation, however when testing the AIs at varying difficulty levels, stronger AIs are still notably winning more so this will become low priority for now.


Inputs

Retested the last test WITH the occasional awarded troops to territories from cards turned off to see if it's just that

Expected outputs

The placement of troops should be improved

Actual outputs

Placement of troops was improved immediately

Pass/Fail

Pass


Inputs

Selecting territories

Expected outputs

The arrow drawn as a visual aid should be from the first territory selected to the cursor, or when a second territory is selected to that territory instead.

Actual outputs

The arrow will occasionally come from the territory selected before the correct one instead

Pass/Fail

Fail

Actions

Warrants further investigation, hoping this is due to some cached state being updated later than intended


Inputs

Saving a malformed board in the board editor

Expected outputs

Should not be possible

Actual outputs

In most cases, the board is blocked from being saved, however if the user attempts to save, is declined, makes one change so that it is valid, saves, reopens the editor, undoes that change and saves, it can save a malformed board.

Pass/Fail

Fail

Actions

Absolutely no idea how to even begin to approach this one, we don't have time to research this issue unfortunately but if we get time, I would definitely start with looking into the location of the validity check first.

Clone this wiki locally