Testing Plan for Inventory system - UQcsse3200/2024-studio-1 GitHub Wiki
The purpose of this plan is to test the basic functionality of Inventory System through testing of the inventory component class. This includes picking up inventory, retrieving them, and resetting the inventory as required.
Test Environment
- Framework: JUnit 4
- Extensions:
GameExtension
for handling libGDX components - Objects Used:
Entity
class representing the player.InventoryComponent
class under test.
Test Cases
-
Entity Association Test
- Purpose: Verify that the entity associated with the
InventoryComponent
is correctly linked with the underlyingInventory
. - Test Method:
testEntityIsSame()
- Expected Outcome: The entity in the
InventoryComponent
should match the entity retrieved from theInventory
.
- Purpose: Verify that the entity associated with the
-
Empty Weapons Test
- Purpose: Confirm that a newly created
InventoryComponent
starts with empty melee and ranged weapon slots. - Test Method:
testWeaponsAreEmpty()
- Expected Outcome: Both melee and ranged weapon slots in the inventory should be empty upon initialization.
- Purpose: Confirm that a newly created
-
Empty Items Test
- Purpose: Ensure that the items list in the inventory is empty upon the creation of a new
InventoryComponent
. - Test Method:
testItemsAreEmpty()
- Expected Outcome: The items list should be empty in the newly initialized
InventoryComponent
.
- Purpose: Ensure that the items list in the inventory is empty upon the creation of a new
-
Melee Weapon Pickup Test
- Purpose: Validate that a melee weapon can be picked up and correctly stored in the inventory.
- Test Method:
testPickupMelee()
- Expected Outcome: The melee weapon slot should contain the picked-up melee weapon.
-
Ranged Weapon Pickup Test
- Purpose: Verify that a ranged weapon can be picked up and stored in the inventory.
- Test Method:
testPickupRanged()
- Expected Outcome: The ranged weapon slot should contain the picked-up ranged weapon.
-
Ranged Weapon Drop Test
- Purpose: Ensure that a ranged weapon can be dropped from the inventory and that it triggers the correct behavior.
- Test Method:
testRangedDrop()
- Expected Outcome: The ranged weapon should be removed from the inventory after being dropped, and a
TestException
should be thrown to confirm the drop logic.
-
Melee Weapon Drop Test
- Purpose: Verify that a melee weapon can be dropped from the inventory and triggers the correct behavior.
- Test Method:
testMeleeDrop()
- Expected Outcome: The melee weapon should be removed from the inventory after being dropped, and a
TestException
should be thrown to confirm the drop logic.
-
Item Addition Test
- Purpose: Validate that an item, such as a
MedKit
, can be added to the inventory. - Test Method:
testItemAdded()
- Expected Outcome: The inventory should contain the added item, confirming that item pickup is functioning correctly.
- Purpose: Validate that an item, such as a
Conclusion
This test plan provides comprehensive coverage of the InventoryComponent
functionality, ensuring that the class correctly handles picking up, retrieving, and resetting melee weapons.