-
Notifications
You must be signed in to change notification settings - Fork 9
Powerups Testing Plan
Powerups play a significant role in the game dynamics and must be tested thoroughly; therefore, PowerupFactory
and PowerupComponent
have been tested in accordance with the following testing plan:
To validate the correct creation and behaviour of powerup entities by the PowerupFactory ensuring:
- Powerup entities are successfully created and are not null.
- Powerup entities created have the expected type, whether a health boost, speed boost or extra life.
- Initialize necessary services and resources needed for testing using ServiceLocator.
- Register the EntityService and PhysicsService using the ServiceLocator.
- Create a new ResourceService instance and load powerup textures (health, speed and extra life) from specified paths.
Objective: To verify the creation of a health powerup entity.
Steps:
- Use PowerupFactory to create a health powerup entity.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is HEALTH_BOOST.
Objective: To verify the creation of a speed powerup entity.
Steps:
- Use PowerupFactory to create a speed powerup entity.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is SPEED_BOOST.
Objective: To verify the creation of an extra life powerup entity.
Steps:
- Use PowerupFactory to create an extra life powerup entity.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is EXTRA_LIFE.
Objective: To verify the creation of a double cross powerup entity.
Steps:
- Use PowerupFactory to create a double cross powerup entity.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is DOUBLE_CROSS.
Objective: To verify the creation of a double damage powerup entity.
Steps:
- Use PowerupFactory to create a double damage powerup entity.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is DOUBLE_DAMAGE.
Objective: To verify the creation of a snap powerup entity.
Steps:
- Use PowerupFactory to create a snap powerup entity.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is SNAP.
Objective: To verify the creation of an immunity powerup entity.
Steps:
- Use PowerupFactory to create an immunity powerup entity.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is TEMP_IMMUNITY.
Objective: To verify the creation of a health powerup config.
Steps:
- Use PowerupConfig to create a health powerup config.
- Check that the created powerup config is not null.
- Use PowerupFactory to create a powerup entity based on the heath powerup config.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is HEALTH_BOOST.
Objective: To verify the creation of a speed powerup config.
Steps:
- Use PowerupConfig to create a speed powerup config.
- Check that the created powerup config is not null.
- Use PowerupFactory to create a powerup entity based on the speed powerup config.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is SPEED_BOOST.
Objective: To verify the creation of a health powerup config.
Steps:
- Use PowerupConfig to create an extra life powerup config.
- Check that the created powerup config is not null.
- Use PowerupFactory to create a powerup entity based on the extra life powerup config.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is EXTRA_LIFE.
Objective: To verify the creation of the double cross powerup config.
Steps:
- Use PowerupConfig to create a double cross powerup config.
- Check that the created powerup config is not null.
- Use PowerupFactory to create a powerup entity based on the double cross powerup config.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is DOUBLE_CROSS.
Objective: To verify the creation of a double damage powerup config.
Steps:
- Use PowerupConfig to create a double damage powerup config.
- Check that the created powerup config is not null.
- Use PowerupFactory to create a powerup entity based on the double damage powerup config.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is DOUBLE_DAMAGE.
Objective: To verify the creation of a Snap powerup config.
Steps:
- Use PowerupConfig to create a Snap powerup config.
- Check that the created powerup config is not null.
- Use PowerupFactory to create a powerup entity based on the Snap powerup config.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is SNAP.
Objective: To verify the creation of an immunity powerup config.
Steps:
- Use PowerupConfig to create an immunity powerup config.
- Check that the created powerup config is not null.
- Use PowerupFactory to create a powerup entity based on the immunity powerup config.
- Extract the PowerupType from the created powerup entity.
- Check that the created powerup entity is not null.
- Validate that the powerup entity type is TEMP_IMMUNITY.
Assumptions:
- The ServiceLocator class works correctly and has been previously tested.
- The PowerupComponent class has methods and behaviour that are correctly implemented. External extensions such as MockitoExtension and GameExtension have the expected behaviour.
The test class relies on external resources such as images (images/healthpowerup.png, images/speedpowerup.png and images/extralifepowerup.png).
To validate the correct behaviour of various power-up effects in the PowerupComponent
class, ensuring:
- The health power-up effectively sets an entity's health to full.
- The speed power-up properly sets an entity's speed.
- The extra life power-up properly increases the player's lives by 1, unless the player has 4 lives.
- The get and set operations for power-up type and duration are accurate.
Objective: To validate the effect of an extra life power-up on an entity's player lives.
Steps:
- Mock necessary components and services.
- Create an extra life power-up component.
- Apply the extra life on a player entity, with 1 life, as defined in
CombatStatsComponent
. - Ensure that the number of player's lives is 2.
- Apply the extra life on the player entity.
- Ensure that the number of player's lives is 3.
Objective: To validate the effect of an extra life power-up on an entity's player lives.
Steps:
- Mock necessary components and services.
- Create an extra life power-up component.
- Apply the extra life on a player entity, with 4 lives, as defined in
CombatStatsComponent
. - Ensure that the number of players' lives is still 4 since the max number of player lives has been reached.
Objective: To validate the effect of a health power-up on an entity's combat stats.
Steps:
- Mock necessary components and services.
- Create a health power-up component.
- Apply the power-up effect on a mock player entity.
- Validate that the player's health is set to full (100).
Objective: To validate the effect of a speed power-up on an entity's player actions.
Steps:
- Mock necessary components and services.
- Create a speed power-up component.
- Apply the speed effect on a mock player entity.
- Ensure the player's speed is set to (5, 5).
Objective: To validate the effect of a temp immunity power-up on an entity's player actions.
Steps:
- Mock necessary components and services.
- Create a temp immunity power-up component.
- Apply the temp immunity effect on a mock player entity.
- Ensure the player and companion are immune.
- Ensure the player and companion are not immune after 7 seconds.
Objective: To validate the effect of a double damage power-up on an entity's player actions.
Steps:
- Mock necessary components and services.
- Create a double damage power-up component.
- Apply the double damage effect on a mock player entity.
- Ensure the player has an attack multiplier of 2.
- Ensure the attack multiplier is reset.
Objective: To validate the effect of a snap power-up on an entity's player actions.
Steps:
- Mock necessary components and services.
- Mock two enemies.
- Create a snap power-up component.
- Apply the snap effect on a mock player entity.
- Ensure that the size of the enemies list is 1.
Objective: To validate the retrieval of the type of power-up component.
Steps:
- Create health and speed power-up components.
- Validate that the type retrieved from each component is accurate.
Objective: To validate the ability to change the type of a power-up component.
Steps:
- Initialize health and speed power-up components.
- Set a new type for each component.
- Validate that the newly set type is retrieved accurately.
Objective: To validate the ability to set the duration of the power-up effect.
Steps:
- Create a health power-up component.
- Set different durations for the power-up effect.
- Ensure that the set duration matches the retrieved value.
Objective: To validate the retrieval of the duration of the power-up effect.
Steps:
- Initialize a health power-up component and set a duration.
- Validate that the retrieved duration is accurate.
- The
PowerupComponentTest
class relies on external libraries likelibGDX
for game-related functionalities. - Mocking frameworks such as Mockito are essential for simulating real-world interactions.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files