Test Plan: CombatStatsComponentTests - UQcsse3200/2024-studio-2 GitHub Wiki
Objective
To ensure the functionality and correctness of the CombatStatsComponent
class, focusing on various attributes such as health, hunger, strength, defense, speed, and experience. The aim is to validate that the component properly handles setting, adding, and bounding these attributes.
Test Coverage
-
Health Management
- Test Case: shouldSetGetHealth
- Purpose: Verify that the health is set and retrieved correctly, adhering to minimum and maximum constraints.
- Steps:
- Initialize
CombatStatsComponent
with default health values. - Set health to various values including within, below, and above the allowed range.
- Verify health is capped at maximum and minimum values.
- Confirm that setting health within bounds is accurate.
- Initialize
- Verification:
- Check that health values are correctly bounded and retrieved.
- Test Case: shouldSetGetHealth
-
Death Status
- Test Case: shouldCheckIsDead
- Purpose: Ensure the
isDead
status accurately reflects the health status. - Steps:
- Initialize
CombatStatsComponent
with non-zero health. - Set health to zero and verify
isDead()
returnstrue
.
- Initialize
- Verification:
- Verify
isDead()
reflects the correct status based on health.
- Verify
- Purpose: Ensure the
- Test Case: shouldCheckIsDead
-
Hunger Management
-
Test Case: shouldSetHungerWithinBounds
- Purpose: Validate that hunger is set correctly within specified bounds.
- Steps:
- Initialize
CombatStatsComponent
with default hunger values. - Set hunger to various values including above and below bounds.
- Confirm hunger values adhere to the allowed range.
- Initialize
- Verification:
- Ensure hunger is capped at maximum and minimum values.
-
Test Case: shouldAddHungerWithCap
- Purpose: Check that adding hunger respects the maximum and minimum bounds.
- Steps:
- Initialize
CombatStatsComponent
. - Add and subtract hunger values and verify hunger does not exceed bounds.
- Initialize
- Verification:
- Confirm hunger is within acceptable limits after addition.
-
-
Strength Management
-
Test Case: shouldSetStrength
- Purpose: Verify strength is set and retrieved correctly, adhering to minimum and maximum constraints.
- Steps:
- Initialize
CombatStatsComponent
with default strength values. - Set strength to various values including within, below, and above the allowed range.
- Initialize
- Verification:
- Ensure strength values are capped and set correctly.
-
Test Case: shouldAddStrength
- Purpose: Ensure that adding strength respects the minimum constraint.
- Steps:
- Initialize
CombatStatsComponent
. - Add and subtract strength values and verify strength does not drop below zero.
- Initialize
- Verification:
- Check that strength is correctly updated and bounded.
-
-
Defense Management
-
Test Case: shouldSetDefense
- Purpose: Confirm that defence is set and retrieved correctly for constraints.
- Steps:
- Initialize
CombatStatsComponent
with default defence values. - Set defence to various values including within, below, and above bounds.
- Initialize
- Verification:
- Verify defence is correctly set and bounded.
-
Test Case: shouldAddDefense
- Purpose: Ensure adding defence respects the minimum constraint.
- Steps:
- Initialize
CombatStatsComponent
. - Add and subtract defence values and verify defence does not drop below zero.
- Initialize
- Verification:
- Confirm that defense is correctly updated and bounded.
-
-
Speed Management
-
Test Case: shouldSetSpeed
- Purpose: Verify that speed is set and retrieved correctly, adhering to minimum and maximum constraints.
- Steps:
- Initialize
CombatStatsComponent
with default speed values. - Set speed to various values including within, below, and above the allowed range.
- Initialize
- Verification:
- Ensure speed values are capped and set correctly.
-
Test Case: shouldAddSpeed
- Purpose: Check that adding speed respects the minimum constraint.
- Steps:
- Initialize
CombatStatsComponent
. - Add and subtract speed values and verify speed does not drop below zero.
- Initialize
- Verification:
- Confirm speed is correctly updated and bounded.
-
-
Experience Management
-
Test Case: shouldSetExperienceAndHandleOverflow
- Purpose: Verify that experience is set correctly and handles overflow as expected.
- Steps:
- Initialize
CombatStatsComponent
with default experience values. - Set experience to values that exceed and fall below bounds.
- Verify experience respects overflow and underflow constraints.
- Initialize
- Verification:
- Check that experience is correctly capped and updated.
-
Test Case: shouldAddExperienceWithOverflow
- Purpose: Ensure adding experience respects overflow constraints and updates correctly.
- Steps:
- Initialize
CombatStatsComponent
. - Add and subtract experience values and verify experience respects overflow limits.
- Initialize
- Verification:
- Confirm experience is correctly updated and bounded.
-
-
Leveling Up
-
Test Case: shouldLevelUpAndIncreaseStats
- Purpose: Validate that levelling up increases stats correctly when experience is gained.
- Steps:
- Initialize
CombatStatsComponent
with specific values. - Add experience to trigger a level-up.
- Verify that stats (health, strength, defense, speed) are increased as expected.
- Initialize
- Verification:
- Ensure stats increase correctly and experience is adjusted.
-
Test Case: shouldLevelUpAndIncreaseStats2
- Purpose: Verify stats increase correctly with experience overflow beyond the maximum.
- Steps:
- Initialize
CombatStatsComponent
. - Set experience to a value that causes level-up.
- Check the updated stats to ensure correct increment.
- Initialize
- Verification:
- Confirm stats increase appropriately and experience is managed.
-
Test Case: shouldNotLevelUpAndIncreaseStats
- Purpose: Ensure that if levelling up is not allowed, stats remain unchanged despite experience gain.
- Steps:
- Initialize
CombatStatsComponent
with levelling disabled. - Add experience and verify no stats are increased.
- Initialize
- Verification:
- Confirm that stats remain unchanged when levelling is disabled.
-
Testing Methodology
- Unit Testing: Verification of individual methods of
CombatStatsComponent
to ensure correct behaviour. - Integration Testing: Testing of interactions between
CombatStatsComponent
and other game components to ensure proper integration. - Automated Testing: Usage of automated tests to verify component behaviour and catch regressions.
Conclusion
By following this test plan, we ensure that the CombatStatsComponent
class performs as expected, handling health, hunger, strength, defense, speed, and experience appropriately. The plan aims to deliver a reliable and robust component, integral to the game's combat system.