CombatStatsComponent Test Plan - UQcsse3200/2023-studio-2 GitHub Wiki
Test Plan for CombatStatsComponent
Introduction:
The CombatStatsComponent
manages the combat statistics of an entity in the game, such as health, damage, and lives. Given its critical role in combat between the player and enemies, it is required to ensure this component satisfies the following test plan.
The following tests were created with a generic entity in mind to ensure the tests are easily extendable for future use.
Objective:
To validate the behaviour and integrity of combat statistics managed by the CombatStatsComponent
, ensuring:
- The correct initialization, retrieval, and setting of combat stats.
- Proper combat interactions between entities (like hitting).
- Accurate event triggering related to combat stats.
Methodology:
Setup (BeforeEach):
- Register the EntityService in ServiceLocator.
- Create an instance of an Entity with the
CombatStatsComponent
. - Mock necessary components like
EventHandler
.
Test Case 1: shouldSetGetHealth
Objective: To verify setting and retrieving health values.
Steps:
- Validate the initial health value.
- Change health and validate the new value.
- Test edge cases (health below zero).
Test Case 2: shouldCheckIsDead
Objective: To check the entity's dead status.
Steps:
- Validate the initial entity's life state.
- Reduce health to zero and verify death status.
- Simulate an attack from another entity and validate death status.
Test Case 3: shouldAddHealth
Objective: To validate adding or subtracting health.
Steps:
- Add health and validate the new value.
- Subtract health and validate the new value.
- Test adding health multiple times.
Test Case 4: shouldSetGetBaseAttack
Objective: To validate setting and retrieving base attack values.
Steps:
- Validate the initial attack value.
- Set and retrieve new attack values.
- Test edge cases (negative attack values).
Test Case 5: shouldSetGetAttackMultiplier
Objective: To validate setting and retrieving attack multiplier values.
Steps:
- Validate the initial multiplier value.
- Change and retrieve the new multiplier value.
- Test edge cases (negative or zero multipliers).
Test Case 6: shouldSetGetImmunity
Objective: To verify setting and retrieving immunity status.
Steps:
- Validate the initial immunity status.
- Change and validate the new immunity status.
Test Case 7: shouldChangeImmunityStatus
Objective: To validate changing the immunity status.
Steps:
- Validate the initial immunity status.
- Change immunity status and validate the new status.
Test Case 8: shouldSetGetLives
Objective: To validate setting and retrieving the number of lives.
Steps:
- Validate the initial number of lives.
- Change and retrieve the number of lives.
- Test edge cases (negative lives or lives set to zero).
Test Case 9: shouldMinusLife
Objective: To validate reducing the number of lives.
Steps:
- Set a specified number of lives.
- Reduce lives and validate the new value.
- Test edge cases (reducing lives from zero).
Test Case 10: shouldAddLife
Objective: To validate adding lives.
Steps:
- Set a specific number of lives.
- Add lives and validate the new value.
- Test edge cases (adding more than the maximum allowed lives).
Test Case 11: shouldTriggerHealthEvent
Objective: To validate the triggering of health update events.
Steps:
- Modify the health of the entity.
- Verify that the "updateHealth" event is triggered.
Test Case 12: shouldTriggerUpdateLivesEvent
Objective: To validate the triggering of lives update events.
Steps:
- Modify the number of lives of the entity.
- Verify that the "updateLives" event is triggered.
Test Case 13: shouldTriggerMaxLivesEvent
Objective: To validate the triggering of a max lives event.
Steps:
- Set the lives of the entity to the maximum.
- Try adding another life.
- Verify that the "maxLivesAlert" event is triggered.