Testing plan for buyable items - UQcsse3200/2024-studio-1 GitHub Wiki
The purpose of this plan is to test the basic functionality of the "buyable" item feature. Specifically, this testing plan aims to test that buyable items can successfully be created, and test cases in which the buyable item is unaffordable and also affordable.
Test Environment
- Framework: JUnit 4
Setup
- A mocked
EntityService
class is registered using the ServiceLocator - A new entity is initialized, representing the player, who has an
InventoryComponent
,ItemPickupComponent
andCoinsComponent
- A new item entity is initialized, representing the buyable item that can be purchased. It has a
BuyableComponent
and aCollectibleComponent
Test case - Testing creation of a buyable item
- Purpose: To verify that buyable items can successfully be created through the create method of the
itemFactory
. The instance created should be a normal item, but with aBuyableComponent
, due to the additional ":buyable" in the specification - Test methods:
testCreateBuyableMedkit()
- Expected outcome: An instance of a MedKit should be successfully created, similar to normal item creation
Test case - Testing the case that the player has sufficient funds
- Purpose: To verify that a buyable item can be purchased when the player has sufficient funds
- Test methods:
sufficientFundsTest()
- Expected outcome: When the cost of the itemEntity is set to 0 (instead of 10 by default), when the player attempts to purchase this item (i.e
checkItemPurchase()
is called), the player's inventory should be appended by this newly purchased item
Test case - Testing the case that the player has insufficient funds
- Purpose: To verify that a buyable item cannot be purchased when the player has insufficient funds
- Test methods:
insufficientFundsTest()
- Expected outcome: When the cost of the itemEntity is 10 (by default), when the player attempts to purchase this item (i.e
checkItemPurchase()
is called), the player's inventory should remain the same, as this item cannot be bought.