End Day Display Test - UQcsse3200/2024-studio-3 GitHub Wiki

Overview

The EndDayDisplayTest class contains unit tests for the EndDayDisplay component of the game, which is responsible for managing the display shown at the end of each game day. These tests ensure that the display functions correctly under various scenarios and that all visual and interactive elements are properly initialized and updated.

Test Environment

Framework: JUnit 5

Mocking Framework: Mockito

Integrated Development Environment (IDE): IntelliJ IDEA

Test Cases

  1. Initial Setup Tests

testAddListeners() Purpose: Verifies that all necessary event listeners are added correctly. Expected Outcome: All event listeners should be registered successfully, and their respective handlers should be invocable.

testCreateBackground() Purpose: Ensures that the background of the display is created and set correctly using a predefined image. Expected Outcome: The background image should be loaded and set as the layout background without issues.

  1. UI Setup Tests

testSetupUI() Purpose: Checks the overall setup of user interface elements within the display. Expected Outcome: All components (spacers, gold display, customer lists, close button) are added to the layout correctly.

testSetUpImages() Purpose: Ensures that all images (bird and points) are initialized and positioned correctly. Expected Outcome: Images should be created, positioned, and added to the stage as expected.

  1. Functional Tests

testHandleGoldUpdate() Purpose: Tests the functionality of updating the gold display when the gold amount changes. Expected Outcome: The gold label should reflect the new amount correctly.

testUpdateCustomerList() Purpose: Verifies the functionality of updating the customer list when a new customer name is added. Expected Outcome: The customer list should be updated with the new customer name.

testShow() Purpose: Tests the visibility and readiness of the display when the show() method is called. Expected Outcome: The display should become visible, and all components should be shown correctly.

  1. Visibility Control Tests

testToggleVisibility_ShouldHideWhenVisible() Purpose: Ensures that the display is hidden when it is currently visible and toggleVisibility() is called. Expected Outcome: The display should transition to a hidden state.

testToggleVisibility_ShouldShowWhenNotVisible() Purpose: Checks that the display becomes visible when it is currently hidden and toggleVisibility() is called. Expected Outcome: The display should transition to a visible state.

Dependencies

MainGameScreen

ServiceLocator and its registered services like RenderService, LevelService, etc.

Tools

Mockito for mocking dependencies and ensuring isolated testing of the component.

JUnit 5 for structuring and running the unit tests.