Skip to content

UpgradesDisplay

Calvin John edited this page Oct 17, 2024 · 3 revisions

Test Environment

  • Framework: JUNIT 5
  • Dependencies:
  • Mockito: For mocking dependencies
  • ParameterizedTest: For testing different inputs

Test Cases

1. testVisibilityOnSetup

  • Purpose: Ensure that when the UpgradesDisplay is created, the visibility of various UI components is correctly set.

  • Setup:

    • Create the UpgradesDisplay object.
    • Check the visibility of the upgrades menu image, table, and buttons.
  • Expected Outcome: The upgrades menu image and table should not be visible initially. Also the buttons within the table should be visible

2. testCreateCallsDependencies

  • Purpose: Ensure that UpgradesDisplay calls key methods during the create() process.
  • Setup: Spy on UpgradesDisplay and check that key methods like addUpgradeImage(), createUpgradesMenuDisplay(), and createButtonsTable() are called.
  • Expected: The key methods should be invoked when create() is called.

3. testToggleVisibility

  • Purpose: Verify that the visibility toggle correctly sets the display to visible.
  • Setup: Toggle visibility and check that the upgrades menu image and table become visible.
  • Expected: UpgradesDisplay, UpgradesMenuImage, and UpgradesTable should be visible, and MainGameScreen.pause() should be invoked.

4. testAddUpgradeImage

  • Purpose: Check that the correct upgrade image is added based on the randomly selected upgrade.
  • Setup: Mock the randomComboService to return different upgrades (Extortion, Speed, Loan, Dance party) and verify the correct texture is loaded.
  • Expected: The correct texture path should be loaded based on the selected upgrade.

5. testCreateButtonsTable

  • Purpose: Ensure that the correct buttons (YES and NO) are created in the upgrades menu.
  • Setup: Call create() and check that the buttons table has two children: YES and NO buttons.
  • Expected: The buttons table should contain YES and NO buttons with the correct labels.

6. testYesButtonClick - same logic used for NoButtonClick

  • Purpose: Verify the behavior when the YES button is clicked (activating the upgrade).
  • Setup: Simulate a YES button click and check that the upgrade is activated, and the visibility is toggled off.
  • Expected: The randomComboService should trigger the activateUpgrade() method, and the response event should be triggered.

7. testDisplayNotEnoughGold

  • Purpose: Check that the notEnoughGold UI is displayed correctly when triggered.
  • Setup: Call displayNotEnoughGoldUI() and check that the appropriate image is displayed on the screen.
  • Expected: The notEnoughGold texture should be loaded and visible in the NotEnoughGoldImages list.

8. testDispose

  • Purpose: Ensure that the resources used by UpgradesDisplay are correctly disposed of.
  • Setup: Call dispose() and verify that the assets associated with the upgrades menu and textures are unloaded.
  • Expected: The upgradesMenuTexture and upgradeTexturePaths should be unloaded from the ResourceService.

9. testInvalidRandomChoice

  • Purpose: Verify behavior when an invalid random choice is selected.
  • Setup: Override getSelectedUpgrade() to return an invalid choice and check that the result is handled appropriately.
  • Expected: An empty string ("") should be returned when an invalid random choice is made.

Sonar Cloud Result For Upgrades

after_all_tests_cropped

Table of Contents

Home

Team Design Document

Game Features

Inventory System
Scoring System
Food Recipes
Level System
Player Actions
Ordering System
Stations
Items
Map Design
Customers
Pause Menu
Upgrades
End of Day Display
Day Night Cycle
Moral System
Debug Terminal
Game Interactions Tutorial
Backstory Cutscenes

Game

Getting Started

Entities and Components

World Backstory

Service Locator

Loading Resources

Logging

Unit Testing

Debug Terminal

Input Handling

UI

Animations

Audio

AI

Physics

Game Screens and Areas

Terrain

Concurrency & Threading

Settings

Map Design

Test Plans

Sensor Component

Customer Sensor Component

Interaction Component

Inventory Component

Inventory Display

Station Meal Component

Station Progress Display

Keyboard Input Component

Fire Extinguisher Handler Component

Score System

HoverBox Component

MainGameActions Create Docket Triggers

End Day Display Component

Cutscene Area

Docket

Docket Line Display

Docket Meal Display

Main Game Order Button Display

Order Actions

Recipe

Ticket Details Component

BackstoryCutscene Test Plan

BackstoryCutsceneDisplay Test Plan

Test Plan for Tutorial

Keybinds

Keybinds Test Plan

Test Plan for MainGameOrderTicketDisplay

Test Plan for MainGameOrderBtnDisplay

Test Plan for Docket

Test Plan for DocketLineDisplay

Test Plan for OrderActions

Ticket Details

Test plan for RandomComboService

Test plan for LoanUpgrade

Test plan for UpgradesDisplay

Test plan for RageUpgrade

Test plan for SpeedBoostUpgrade

Test plan for DancePartyUpgrade

Test plan for ExtortionUpgrade

Troubleshooting

MacOS Setup Guide

Clone this wiki locally