Testing Plan for Range Detection Component - UQcsse3200/2024-studio-1 GitHub Wiki

Objective

The purpose of this test plan is to validate the functionality of the RangeDetectionComponent class within the game. This component is responsible for detecting entities within a certain range, which is crucial for gameplay mechanics such as combat and interaction. The tests aim to ensure that all functionalities such as component creation, entity detection, and attribute handling work as expected.

Test Environment

Framework: JUnit 4 and JUnit 5 (Jupiter)

Extensions: Mockito for mocking dependencies

Objects Used:

  • RangeDetectionComponent class representing the range detection functionality.
  • Entity class representing game entities (player, enemy).
  • CombatStatsComponent for combat-related attributes.
  • WeaponComponent for weapon-related functionality.
  • HitboxComponent for collision detection.
  • PhysicsLayer enum for specifying collision layers.

Setup:

  • The setUp() method initializes key components before each test case, ensuring a consistent and clean test environment.
  • Mocks are created for Entity, CombatStatsComponent, WeaponComponent, and HitboxComponent.
  • A RangeDetectionComponent is created with PhysicsLayer.NPC.

Test Cases

Test Case 1: Range Detection Component Creation

Objective: Validate that the RangeDetectionComponent is created successfully.

Setup: Create a RangeDetectionComponent with PhysicsLayer.NPC.

Expected Outcome: rangeDetectionComponent is not null.


Test Case 2: Update Weapon Entity

Objective: Ensure that the updateWeaponEntity method correctly sets the HitboxComponent.

Setup:

  1. Create a RangeDetectionComponent.
  2. Call updateWeaponEntity with a mocked player Entity.

Expected Outcome:

  • Before updateWeaponEntity, getHitboxComponent() returns null.
  • After updateWeaponEntity, getHitboxComponent() returns a non-null HitboxComponent.

Test Case 3: Create Entities List

Objective: Verify that the entities list is properly initialized.

Setup: Create a new RangeDetectionComponent.

Expected Outcome:

  • getEntities() returns a non-null ArrayList.
  • The initial size of the entities list is 0.

Test Case 4: Get Entities

Objective: Validate that the getEntities method returns the correct list of entities.

Setup: Create a RangeDetectionComponent and add entities to it.

Expected Outcome:

  • getEntities() returns a non-null ArrayList.
  • The size of the returned list matches the number of added entities.

  • Note: some functionality such as add element or remove elements from the entities list can not be test as this will be triggered via events service call (CollisionStart).

Integration Testing

  1. Entity Lifecycle with Range Detection:

    • Test the complete lifecycle of an entity with RangeDetectionComponent from creation to destruction.
    • Verify that range detection works correctly with physics components and entity movement.
  2. Range Transitions:

    • Ensure smooth transitions when entities enter and exit the detection range.
  3. Component Interaction:

    • Verify that RangeDetectionComponent interacts correctly with CombatStatsComponent and WeaponComponent.
  4. Multi-Entity Scenarios:

    • Test range detection with multiple entities of different types (e.g., players, NPCs, projectiles).
  5. Physics Layer Interaction:

    • Verify correct execution of range detection across different physics layers:
      • Entity Detection: Check that only entities on the specified layer are detected.
      • Layer Transitions: Test behavior when entities change layers.
  6. Event System Integration:

    • Verify correct triggering and handling of events related to range detection (e.g., entity entered/exited range).

Playtesting

Focus on the following aspects:

  1. Detection Behavior:

    • Ensure that entities are detected consistently and accurately within the specified range.
    • Verify that detection feels natural and doesn't cause unexpected gameplay behavior.
  2. Visual Feedback:

    • Check that there's clear visual feedback when entities enter or exit the detection range (if applicable).
  3. Performance:

    • Assess any performance issues with multiple entities being detected simultaneously.
  4. Range Consistency:

    • Observe if the detection range feels consistent across different scenarios and environments.
  5. Interaction with Game Mechanics:

    • Assess how range detection affects other game mechanics (e.g., combat, AI behavior).
  6. Edge Case Scenarios:

    • Evaluate range detection in various game situations (e.g., crowded environments, through obstacles, at map edges).

Potential User Testing

Consider the following methods and topics:

  1. Think-aloud Protocol:

    • Have users verbalize thoughts as they interact with entities that have range detection capabilities.
  2. Questionnaires:

    • Ask about the intuitiveness of range-based mechanics in the game.
    • Gather opinions on the perceived accuracy and consistency of range detection.
  3. Interviews:

    • Conduct post-play interviews for detailed feedback on how range detection affects gameplay experience.
  4. Direct Player Feedback:

    • Get feedback on how noticeable and impactful range detection is during gameplay.
  5. Surveys:

    • Understand player perception of range-based mechanics and their impact on game strategies.
  6. User Experience (UX) Metrics:

    • Track engagement time with range-based mechanics, frustration levels, and overall enjoyment related to range detection interactions.

Conclusion

This expanded test plan provides comprehensive coverage of the RangeDetectionComponent functionality, ensuring that range detection, entity tracking, and related gameplay mechanics are correctly handled across different scenarios. The inclusion of integration testing, playtesting, and user testing ensures a thorough evaluation of the range detection system from both technical and user experience perspectives. This approach will help identify any issues with the component's implementation and its impact on overall gameplay, allowing for refinement and optimization of the range detection mechanics.