Upgrade Tree Testing Plan - UQcsse3200/2023-studio-2 GitHub Wiki
Test Plan for UpgradeNode
Objective:
To validate the correct behavior of the UpgradeNode
class ensuring:
- Upgrade nodes are successfully created and store the correct weapon information.
- Child nodes can be added to an upgrade node.
- The
x
andy
coordinates, as well as the depth of a node, can be set and retrieved accurately.
Methodology:
Setup (BeforeEach):
- Mock necessary components and services.
- Create a sample
WeaponConfig
andWeaponType
for testing purposes.
Test Case 1: testNodeCreation
Objective: To verify the creation of an upgrade node.
Steps:
- Use the
UpgradeNode
constructor to create a new node. - Validate that the node's
imagePath
andweaponType
matches the respective node data.
Test Case 2: testAddChildNode
Objective: To validate the addition of a child node.
Steps:
- Create an upgrade node instance.
- Add a child node to the created node using
addChild
. - Validate that the child node has been added successfully.
Test Case 3: testSetAndGetCoordinates
Objective: To verify setting and getting the x and y coordinates of a node.
Steps:
- Create an upgrade node instance.
- Set the
x
andy
coordinates usingsetX
andsetY
. - Validate that the set coordinates match the retrieved values.
Test Case 4: testSetAndGetDepth
Objective: To validate setting and getting the depth of a node.
Steps:
- Create an upgrade node instance.
- Set a depth value using
setDepth
. - Validate that the set depth matches the retrieved value.
Dependencies:
WeaponConfig
andWeaponType
are required to test tree nodes.
Test Plan for UpgradeTree
Objective:
To validate the correct behavior of the UpgradeTree
class ensuring:
- Weapons can be unlocked and checked if they are unlocked.
- Materials can be retrieved and subtracted accurately (with respect to extractor resources)
Methodology:
Setup (BeforeEach):
- Mock necessary components and services.
- Initialize a new
UpgradeTree
instance.
Test Case 1: testUnlockWeapon
Objective: To verify the ability to unlock a weapon.
Steps:
- Unlock a weapon using
unlockWeapon
. - Validate that the weapon is added to the list of unlocked weapons (including default weapons).
Test Case 2: testIsWeaponUnlocked
Objective: To verify if a weapon is unlocked or not.
Steps:
- Unlock a weapon using
unlockWeapon
. - Use
isWeaponUnlocked
to check if the weapon is unlocked. - Validate that it returns
true
.
Test Case 3: testGetMaterials
Objective: To validate the retrieval of materials.
Steps:
- Mock the game's state observer to return a certain amount of materials.
- Use
getMaterials
to retrieve the amount. - Validate that the retrieved amount matches the mock value.
Test Case 4: testSubtractMaterials
Objective: To verify the subtraction of materials.
Steps:
- Mock the game's state observer to return a certain amount of materials.
- Subtract a certain amount using
subtractMaterials
. - Validate that the correct amount has been subtracted.
Dependencies:
- The
UpgradeTreeTest
class relies on the game's state observer to function correctly. - Mockito is required to mock game state resources.
Test Plan for UpgradeDisplay
Objective:
To validate the displaying of the Upgrade Tree window is correct, including:
- Weapons not apart of the default unlocked weapons are locked.
- All locked nodes are greyed out, have a lock overlay, and have a purchase button.
- The tree draws and spaces the nodes appropriately, ensuring they do not overlap.
- Lines and node backgrounds are drawn in correct order such that lines do not overlay weapon and background sprites.
Methodology:
As the test class heavily depends on visuals, it is difficult to ensure from unit tests alone - therefore various visual tests were conducted.
Visual Testing
Sprint 2:
1: Basic Tests
- Are node sprites, lines, and backgrounds drawn?
- Are the default weapons unlocked (stick, slingshot ball, woodhammer)?
- Are the materials and exit buttons located appropriately?
- Does the exit button remove the window from the stage?
- Is there enough space between nodes (horizontally and vertically)?
- Is there any overlapping? (locks, lines, backgrounds)
- Does clicking the upgrade button with enough resources remove the lock, and lighten the image (indicating unlocked) or vice versa?
- Does the upgrade button animate down and up on button presses?
Example: Base upgrade tree window
2: Node addition and removal testing
- Does adding a new node space correctly in the tree?
- Does removing a root node resize all trees correctly?
- If multiple nodes are added, do they space correctly?
Example: Melee Root node removed, multiple children added to ranged tree
Sprint 3:
1: Setup
- Ensure all tests from Sprint 2 pass.
2: Node Interaction and Display
- Ensure lines are correctly coloured between locked/unlocked nodes.
- Ensure correct equipped-item numbers and border is displayed correctly.
- Ensure hovering mouse displays the weapon stats tooltip.
3: Window and Aspect Ratio
- Ensure aspect ratio is maintained for windowed and fullscreen modes so that it is consistent with bug fixes in sprint 2.
4: Game State and Dynamic Updates
- Ensure the materials dynamically update in accordance with game state resources (Nebulite).