Test Plan for Scoring System - UQcsse3200/2024-studio-1 GitHub Wiki
Objective
The purpose of this test plans to valid the functionality of scoring system, which adds a certain number of coins based on NPC's Strength
Unit Test Plan for CoinsComponentTest
Test Environment
- FrameWork: JUnit5
 - Objects Used:
Entityclass representing the player,InventoryComponentandCoinsComponentrepresenting the player's inventory and player's score. Moreover,Event Handlerto represent the events of players. 
SetUp() Method
The setUp() method initializes key components before each test case, ensuring a consistent and clean test environment.
- Player Entity (
player): A newEntityinstance is created, representing the player. - InventoryComponent (
inventoryComponent): Manages the player's inventory, crucial for testing item and weapon saving. - CombatStatsComponent (
statsComponent): Stores the player's coins gained from defeating the animals. 
Test Cases
1. Test Case: testInitialCoinCount()
- Objective: Verify that a new game starts with zero coins.
 - Setup:
- Initialize 
CoinsComponent. 
 - Initialize 
 - Execution: Call 
getCoins()to check the initial coin count. - Expected Outcome: The initial coin count should be 0.
 
2. Test Case: testSpendCoins()
- Objective: Verify that spending coins reduces the amount of coins the player owns.
 - Setup:
- Set the player's coins to 10 using 
setCoins(10). 
 - Set the player's coins to 10 using 
 - Execution:
- Call 
spend(4)to reduce the coins by 4. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should be 6 after spending 4 coins.
 
3. Test Case: testSpendEverything()
- Objective: Verify that spending all the money reduces the coin count to 0.
 - Setup:
- Set the player's coins to a large amount, such as 1,000,000,000, using 
setCoins(1000000000). 
 - Set the player's coins to a large amount, such as 1,000,000,000, using 
 - Execution:
- Call 
spend(1000000000)to spend all the coins. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should be 0 after spending all coins.
 
4. Test Case: testAddCoins()
- Objective: Verify that calling 
addCoins()adds coins to the player's coin count. - Setup:
- Initialize 
CoinsComponentwithout adding any coins. 
 - Initialize 
 - Execution:
- Call 
addCoins(5)to add 5 coins. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should be 5 after adding 5 coins.
 
5. Test Case: testAddNegativeCoins()
- Objective: Verify that negative coins cannot be added to the player's coin count.
 - Setup:
- Initialize 
CoinsComponentwithout adding any coins. 
 - Initialize 
 - Execution:
- Call 
addCoins(-2)to attempt adding negative coins. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should be 0 since negative amounts cannot be added.
 
6. Test Case: testSetCoins()
- Objective: Verify that calling 
setCoins()changes the stored amount of coins. - Setup:
- Initialize 
CoinsComponentwithout adding any coins. 
 - Initialize 
 - Execution:
- Call 
setCoins(10)to set the coin count to 10. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should be 10 after setting it to 10.
 
7. Test Case: testSetNegativeCoins()
- Objective: Verify that coins cannot be set to a negative number.
 - Setup:
- Initialize 
CoinsComponentwithout adding any coins. 
 - Initialize 
 - Execution:
- Call 
setCoins(-5)to attempt setting a negative coin count. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should be 0 as negative values are not allowed.
 
8. Test Case: testSet0Coin()
- Objective: Verify that setting the amount to zero reduces the amount of coins to zero.
 - Setup:
- Initialize 
CoinsComponentand set some coins (if necessary). 
 - Initialize 
 - Execution:
- Call 
setCoins(0)to set the coin count to 0. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should be 0 after setting it to 0.
 
9. Test Case: testHasCoins()
- Objective: Verify that 
hasCoins()correctly checks if the player has the specified amount of coins. - Setup:
- Set the player's coins to 10 using 
setCoins(10). 
 - Set the player's coins to 10 using 
 - Execution:
- Call 
hasCoins(5)to check if the player has at least 5 coins. - Call 
hasCoins(20)to check if the player has at least 20 coins. 
 - Call 
 - Expected Outcome:
hasCoins(5)should returntrueas the player has 10 coins.hasCoins(20)should returnfalseas the player has only 10 coins.
 
10. Test Case: testSpendMoreThanAvailableCoins()
- Objective: Verify that the player is not able to spend more money than they have.
 - Setup:
- Set the player's coins to 5 using 
setCoins(5). 
 - Set the player's coins to 5 using 
 - Execution:
- Call 
spend(10)to attempt spending more than available. - Call 
getCoins()to get the current coin count. 
 - Call 
 - Expected Outcome: Coin count should remain 5 as the player cannot spend more than they have.
 
Manual UI Testing Plan
Objective: Verify the behavior of the CoinsComponent in a real gameplay scenario.
1. Scenario: Initial Coin Count
- Task: Start a new game and check the initial coin count displayed on the screen.
 - Expected Outcome: The initial coin count should be displayed as 0.
 
2. Scenario: Collecting Coins
- Task: Pick up different coin items (3, 6, 9, 10 coins) scattered in the game world.
 - Expected Outcome: The coin count should increase accordingly as each coin item is picked up.
 
3. Scenario: Spending Coins
- Task: Try to spend coins by purchasing an in-game item.
 - Expected Outcome: The coin count should decrease based on the item's cost.
 
4. Scenario: Spending More Than Available
- Task: Try to purchase an item costing more than the current coin count.
 - Expected Outcome: The purchase should be blocked, and a message indicating insufficient funds should be displayed.
 
7. Scenario: Display Accuracy
- Task: Continuously add and spend coins in different amounts and verify that the coin count displayed is always accurate.
 - Expected Outcome: The coin count should always reflect the accurate amount of coins owned by the player.