HoverBox Component Test Plan - UQcsse3200/2024-studio-3 GitHub Wiki

HoverBoxComponent Test Plan

1. Introduction

This test plan outlines the strategy for verifying the functionality and reliability of the HoverBoxComponent class, which is responsible for rendering a hover box in the game. The plan covers various methods including texture setting, updating, drawing, and other utility functions.

2. Test Objectives

The primary objectives of this test plan are to:

  1. Verify the correct setting and retrieval of textures for the hover box.
  2. Ensure the component updates its position and scale based on the associated entity.
  3. Validate the drawing behaviour under different entity states (valid, null, zero position).
  4. Confirm the correct render layer is returned.
  5. Verify the proper handling of stage setting.

3. Test Cases

3.1 Texture Handling

Test Case 3.1.1: Set Texture

  • Test Method: testSetTexture()
  • Objective: Verify that a new texture can be set and retrieved correctly
  • Expected Result: The newly set texture should be returned by getTexture()

3.2 Update Functionality

Test Case 3.2.1: Update Position and Scale

  • Test Method: testUpdate()
  • Objective: Verify that the component updates its position and scale based on the entity
  • Expected Result: The component's position and scale should match the entity's values after update

3.3 Draw Functionality

Test Case 3.3.1: Draw with Valid Entity

  • Test Method: testDraw_WithValidEntity()
  • Objective: Verify correct drawing when the component has a valid entity
  • Expected Result: SpriteBatch.draw() should be called with the correct parameters

Test Case 3.3.2: Draw with Null Entity

  • Test Method: testDraw_WithNullEntity()
  • Objective: Verify that no drawing occurs when the entity is null
  • Expected Result: SpriteBatch.draw() should not be called

Test Case 3.3.3: Draw with Zero Position

  • Test Method: testDraw_WithZeroPosition()
  • Objective: Verify that no drawing occurs when the entity is at position (0,0)
  • Expected Result: SpriteBatch.draw() should not be called

3.4 Utility Functions

Test Case 3.4.1: Get Render Layer

  • Test Method: testGetLayer()
  • Objective: Verify the correct render layer is returned
  • Expected Result: The method should return 3

Test Case 3.4.2: Set Stage

  • Test Method: testSetStage()
  • Objective: Verify that setting a stage doesn't cause errors
  • Expected Result: The method should execute without throwing exceptions

4. Test Execution

  • Java Development Kit (JDK) version used in the project
  • JUnit 5 testing framework for unit tests
  • Mockito framework for mocking dependencies