Testing plan for items - UQcsse3200/2024-studio-1 GitHub Wiki
The purpose of this plan is to test the basic functionality of all four items, through testing of the their 'get()' methods extending from the UsableItem
and BufItem
classes, as well as testing methods that 'apply to' or 'affect' the player. Such methods are unique to each item.
Test Environment
- Framework: JUnit 4
Test Cases - Testing 'get()' methods of all items
1. Retrieving name of the item
- Purpose: To verify that the name of the specific item is correctly returned
- Test methods:
testGetName()
andgetNameTest()
- Expected outcome: The name retrieved using the
getName()
method should correctly return the name of the item
2. Retrieving the specific specification of the item
- Purpose: To verify that the specific specification of the item is correctly returned
- Test methods:
testGetItemSpecification()
andgetItemSpecificatonTest()
- Expected outcome: The string retrieved using the
getItemSpecification()
andgetBuffSpecification()
method should correctly return the specification associated with item (eg. "bandage")
3. Retrieving the full specification of the item
- Purpose: To verify that the full specification of the item is correctly returned
- Test methods:
testGetSpecification()
andgetSpecificationTest()
- Expected outcome: The string retrieved using the
getSpecification()
method should correctly return the full specification associated with item (eg. "item:bandage" or buff:armor)
4. Retrieving the type of the buff item
- Purpose: To verify that the type of the buff item is correctly returned
- Test methods:
getTypeTest()
in EnergyDrinkTest - Expected outcome: The Type returned by this method should be the Type.BUFF_ITEM
Test Cases - Testing unique 'get()' methods of certain classes
1. Retrieving the Energy Drink speed vector
- Purpose: To verify that the correct speed vector is returned
- Test methods:
getSpeedTest()
in EnergyDrinkTest - Expected outcome: The vector retrieved using the
getSpeed()
method should correctly return the speed vector associated with this Energy Drink type
2. Retrieving the maximum speed limit of the player
- Purpose: To verify that the correct maximum speed boost is obtained
- Test methods:
maxSpeedTest()
in EnergyDrinkTest - Expected outcome: The value retrieved using the
getMaxTotalSpeedBoost()
method of the PlayerActions class should correctly return the maximum speed boost (0.5%)
3. Retrieving the buff effect of the Damage Buff item
- Purpose: To verify that the correct buff value was returned
- Test methods:
testGetBuff()
in DamageBuffTest - Expected outcome: The value retrieved using the
getBuuf()
method should correctly return the buff effect value (5)
4. Retrieving the base Damage Buff value applied to the player (before any buff items are applied)
- Purpose: To verify that the initial, starting Damage Buff value applied to the player is correctly returned
- Test methods:
testBaseDamageBuff()
in DamageBuffTest - Expected outcome: The value retrieved using the
getDamageBuff()
method should correctly return the initial Damage Buff value (0)
5. Retrieving the effect that the armor would have on the player
- Purpose: To verify that the correct armor value was returned
- Test methods:
testArmorItem()
in ArmorTest - Expected outcome: The value retrieved using the
getArmor()
method should correctly return the armor effect value (10)
6. Retrieving the base armor value applied to the player (before any armor items are applied)
- Purpose: To verify that the initial, starting armor value applied to the player is correctly returned
- Test methods:
testBaseEntityArmor()
in ArmorTest - Expected outcome: The value retrieved using the
getArmor()
method should correctly return the initial armor value (0)
Test Cases - Testing methods that "apply to" or "affect" the player
Bandage
1. Bandage effects
- Purpose: To verify that the the
apply()
method of the Bandage increases the player's health by the expected amount and caps it at 100 when required. - Test methods:
testApplyIncreasesHealth()
andtestApplyIncreasesHealthFromZero()
in BandageTest - Expected outcome: The
setHealth
method from the combatStatsComponent should be called with the expected Health for both the functionstestApplyIncreasesHealth()
andtestApplyIncreasesHealthFromZero()
.
Bear Trap
1. Bear Trap effects
- Purpose: To verify that the
apply()
method of the Bear Trap correctly spawns a Bear Trap entity at the player's current position. - Test methods:
testApplySpawnsBearTrap()
(commented out in the provided test code but will test this in sprint 4). - Expected outcome: The
spawnEntityAt
method fromGameAreaService
should be called with the Bear Trap entity and the player's current position as the spawn location.
Divine Potion
1. Divine potion Health Boost
- Purpose: Verify that the
Boost()
method correctly increases the player's health by the specified amount, but does not exceed the player's maximum health. - Test methods:
testDivinePotionBoostHealth()
- Expected outcome: The player's health is increased by
potionBoost
, but does not exceed the maximum health. ThesetHealth()
method ofCombatStatsComponent
should be called with the expected new health value.
2. Speed Boost with Max Speed Limit
- Purpose: Test that the
speed()
method boosts the player's speed, but caps it at the maximum allowed speed if the new speed exceeds the limit. - Test methods:
testSpeedBoostWithMaxSpeedLimit()
- Expected outcome: The player's speed should be capped at 6f in both directions (x and y). The speed percentage should also be capped at 1.0f, and an event should be triggered to update the UI with this capped speed.
3. Speed Boost Below Max Speed
- Purpose: Verify that the
speed()
method increases the player's speed by a fixed boost amount when the current speed is below the maximum speed limit. - Test methods:
testSpeedBoostBelowMaxSpeed()
- Expected outcome: The player's speed should increase by .25f in both x and y directions, and the new speed percentage should be updated accordingly (from 0.5f to 0.75f). An event should be triggered to update the UI with the new speed percentage.
Heart
1. Heart item effects
- Purpose: To verify that the
effect()
method of the Heart item increases the player's maximum health by the expected amount. - Test methods:
testHeartIncreasesMaxHealth()
- Expected outcome: The
setMaxHealth()
method fromCombatStatsComponent
should be called with the new maximum health value, which is the sum of the player's current maximum health and the health increase. The value should not exceed the defined maximum limit (150).
MedKit
1. Medkit effects
- Purpose: To verify that the the
apply()
method of the Medkit increases the player's health by the expected amount and caps it at 100 when required. - Test methods:
testApplyIncreasesHealth()
andtestApplyIncreasesHealthFromZero()
in MedkitTest - Expected outcome: The
setHealth()
method from the combatStatsComponent should be called with the expected Health for both the functionstestApplyIncreasesHealth()
andtestApplyIncreasesHealthFromZero()
.
Shield potion
1. Shield potion effects
- Purpose: To verify that the the
apply()
method of the shield potion works as expected - Test methods:
testApply()
,testNegateHit()
,testNegateHitWhenInactive()
in ShieldPotionTest - Expected outcome: In the first test, the number of charges should be 0 before application, and 2 after applying the potion. In the second test, upon triggering the "hit" event after applying the potion, the number of charges should decrease. In the third test, upon triggering the "hit" event when the potion has not been applied, the number of charges should still remain 0.
Syringe
1. Syringe effects
- Purpose: To verify that the
effect()
method of the Syringe increases the player's health by the expected amount. - Test methods:
testSyringeIncreaseHealth()
in SyringeTest - Expected outcome: The
addHealth()
method from the combatStatsComponent should be called with the correct boost value and final health should be equal to expected health after Syringe is applied.
Energy drink
1. Basic energy drink effects
- Purpose: To verify that the energy drink correctly updates the player's speed, as well as calculates the correct speed boost to update the UI with
- Test methods:
effectTest()
in EnergyDrinkTest - Expected outcome: Before applying the
effect()
method of the energy drink on the entity (representing the player), the player's initial speed should be the base speed (defined to be Vector2(3f, 3f) in the player config mocked during thesetup()
), and the initial speed boost (calculated usinggetSpeedProgressBarProportion
) should be 0.0. After applying the effect, the player's speed and calculated speed boost should be updated to the expected amount.
2. Energy drink effects when speed is at its maximum limit
- Purpose: To verify that the energy drink will not affect the player's speed or speed percentage (used for the UI) if their speed is already at a maximum
- Test methods:
effectTestMax()
in EnergyDrinkTest - Expected outcome: The player's maximum speed is obtained using
getMaxPlayerSpeed()
of the PlayerActions class. Initially, the player's speed is set to this maximum. When the energy drink is applied using theeffect()
method, it is expected that the player's speed should be capped at the maximum speed. The maximum speed is expected to be 0.5% of the base speed + the base speed. Additionally, the speed boost (calculated usinggetSpeedProgressBarProportion
) used for the UI should also be the maximum, which is 0.5.
Damage buff item
1. Application of the Damage Buff item to the player
- Purpose: To verify that the effect method of the damage buff item correctly updates the damage buff of the player
- Test methods:
testDamageBuff()
in DamageBuffTest - Expected outcome: After applying the damage buff item using the
effect()
method, the damage buff of the player should be updated to the correct amount (5). The damage buff of the player can be obtained using thegetDamageBuff()
method of the CombatStatsComponent class
2. Applying the Additional Damage Buff to the enemy
- Purpose: To determine if the damage buff increases damage of the player when attacking enemies
- Test methods:
testAdditionalDamage()
in DamageBuffTest - Expected outcome: After applying the buff to the player the victim should have health reduced to 90 instead of 95.
Armor item
1. Application of the armor to the player
- Purpose: To verify that the effect method of the armor item correctly updates the armor value of the player
- Test methods:
testIncreaseEntityArmor()
in ArmorTest - Expected outcome: After applying the armor item using the
effect()
method, the armor value of the player should be updated to the correct amount (10). The damage buff of the player can be obtained using thegetArmor()
method of the CombatStatsComponent class
2. Application of the armor to the player when damage from entities attackers
- Purpose: To verify that after application, the armor correctly reduces damage from attackers
- Test methods:
testDamageNoArmor()
andtestDamageReduction()
in ArmorTest - Expected outcome: The first test verifies that without armor, the health of the player should decrease (from 100 to 85) after a "hit" is induced by an attacker. The second test verifies that the with armor, the player's health should decrease by a smaller amount (from 100 to 87) after a "hit".
`