Skip to content

CombatStatsComponent Test Plan

connor-golin edited this page Oct 4, 2023 · 4 revisions

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:

  1. Validate the initial health value.
  2. Change health and validate the new value.
  3. Test edge cases (health below zero).

Test Case 2: shouldCheckIsDead

Objective: To check the entity's dead status.

Steps:

  1. Validate the initial entity's life state.
  2. Reduce health to zero and verify death status.
  3. Simulate an attack from another entity and validate death status.

Test Case 3: shouldAddHealth

Objective: To validate adding or subtracting health.

Steps:

  1. Add health and validate the new value.
  2. Subtract health and validate the new value.
  3. Test adding health multiple times.

Test Case 4: shouldSetGetBaseAttack

Objective: To validate setting and retrieving base attack values.

Steps:

  1. Validate the initial attack value.
  2. Set and retrieve new attack values.
  3. Test edge cases (negative attack values).

Test Case 5: shouldSetGetAttackMultiplier

Objective: To validate setting and retrieving attack multiplier values.

Steps:

  1. Validate the initial multiplier value.
  2. Change and retrieve the new multiplier value.
  3. Test edge cases (negative or zero multipliers).

Test Case 6: shouldSetGetImmunity

Objective: To verify setting and retrieving immunity status.

Steps:

  1. Validate the initial immunity status.
  2. Change and validate the new immunity status.

Test Case 7: shouldChangeImmunityStatus

Objective: To validate changing the immunity status.

Steps:

  1. Validate the initial immunity status.
  2. Change immunity status and validate the new status.

Test Case 8: shouldSetGetLives

Objective: To validate setting and retrieving the number of lives.

Steps:

  1. Validate the initial number of lives.
  2. Change and retrieve the number of lives.
  3. Test edge cases (negative lives or lives set to zero).

Test Case 9: shouldMinusLife

Objective: To validate reducing the number of lives.

Steps:

  1. Set a specified number of lives.
  2. Reduce lives and validate the new value.
  3. Test edge cases (reducing lives from zero).

Test Case 10: shouldAddLife

Objective: To validate adding lives.

Steps:

  1. Set a specific number of lives.
  2. Add lives and validate the new value.
  3. Test edge cases (adding more than the maximum allowed lives).

Test Case 11: shouldTriggerHealthEvent

Objective: To validate the triggering of health update events.

Steps:

  1. Modify the health of the entity.
  2. Verify that the "updateHealth" event is triggered.

Test Case 12: shouldTriggerUpdateLivesEvent

Objective: To validate the triggering of lives update events.

Steps:

  1. Modify the number of lives of the entity.
  2. Verify that the "updateLives" event is triggered.

Test Case 13: shouldTriggerMaxLivesEvent

Objective: To validate the triggering of a max lives event.

Steps:

  1. Set the lives of the entity to the maximum.
  2. Try adding another life.
  3. Verify that the "maxLivesAlert" event is triggered.
Clone this wiki locally