Testing Plans - UQcsse3200/2024-studio-2 GitHub Wiki

Testing Plan

This wiki outlines the testing plan for the Snake mini-game, detailing the testing approach, the files involved, and specific classes that require visual checks rather than traditional unit testing.

Testing Approach

1. Unit Testing

  • Objective: Ensure that individual components of the Snake mini-game function as expected in isolation.
  • Tools: JUnit for automated testing of core game logic.
  • Scope: Focuses on testing the fundamental elements such as the apple, snake, grid, and score mechanisms.

2. UI/Visual Checks

  • Objective: Confirm that the visual elements and interactions within the game screens work correctly.
  • Scope: Includes verifying screen transitions, button functionality, and visual feedback based on user actions.

Testing Files

Below are the key testing files used for unit testing various components of the Snake mini-game:

  1. AppleTest.java

    • Tests the functionality of the apple component, ensuring proper behaviour when the snake interacts with it.
      View Source
  2. EventsTest.java

  3. SnakeTest.java

    • Tests the behavior of the snake, particularly its movement and collision detection.
      View Source
  4. SnakeGridTest.java

    • Ensures the grid cells function correctly, particularly their interaction with the snake and other objects.
      View Source
  5. SnakeGameTest.java

    • Tests the game works as expected with the snake, grid and apples. View Source

Classes Unable to Be Tested

Some classes require visual confirmation and cannot be easily tested through unit tests:

  1. EndSnakeScreen

    • Works as expected if all labels are visible, and the exit, restart, and menu buttons are functional. Additionally, 'R' and 'Esc' keys should restart the game or return to the mini-game menu. The background color and message should change depending on the medal earned (green for fail, bronze for bronze, silver for silver, and gold for gold).
  2. MiniGameMenuScreen

    • Works as expected if the images for Snake, Bird, and Fish with corresponding buttons and an exit button in the corner load and work. The 'Esc' key should return to the previous menu.
  3. SnakeScreen, Events, and SnakeController

    • Works as expected if the grid, apples, snake, and scoreboard are loaded correctly. The snake should respond to "WASD" and arrow keys, and the game should terminate upon collision with itself or the border. Additionally, 'R' and 'Esc' keys should restart the game or return to the mini-game menu.
  4. Rendering Classes

    • Classes like AppleRenderer, GridRenderer, SnakeRenderer and SnakeGameRenderer are confirmed to work if the corresponding visuals are displayed correctly on the respective screens.