Skip to content

GameState Testing Plan

Henry Batt edited this page Aug 31, 2023 · 1 revision

Introduction:

The Game State is a key component of the game's functionality being in charge of the storing and saving of shared, global game data. As such it is vital that it is tested thoroughly to ensure it behaves exactly as expected.

Test Plan:

Objective:

The objective is to validate the behaviour of the game state by ensuring:

  • The update and storage data of is accurate.
  • When data is attempted to be retrieved it is the most recent version.
  • That state change listeners can be registered and work correctly.

Methodology:

SetUp (BeforeEach)

  • A new GameState is created with no data.

Test Case 1: testPutAndGet

Objective: To ensure that data is correctly added and retrieved from the state.

Steps:

  • Data is added into the GameState in a key-value pair.
  • Data is then retrieved using the selected key.
  • Validation of original inputted data and retrieved data is identical.

Test Case 2: testStateChangeListenerNotification

Objective: Verify that a listener gets notified of a state change.

Steps:

  • Register a listener for a state change.
  • Add data to the game state to trigger a state change.
  • Verify that the state listener was notified that a state change occurred.
  • Verify that the listener has the updated state data.

Test Case 3: testMultipleStateChangeListeners

Objective: To verify that multiple state listeners can be registered and work correctly.

Steps:

  • Register two state change listeners
  • Update the GameState to trigger the notification
  • Verify that the first listener gets notified and access to the updated data.
  • Verify that the second listener gets notified and access to the updated data.

Test Case 4: testUnregisterStateChangeListener

Objective: To ensure that when a state listener unregisters from the state change notifications it no longer gets notified.

Steps:

  • Register a state change listener
  • Unregister the state change listener
  • Update the GameState to trigger a notification
  • Validate that the listener did not receive a notification.
Clone this wiki locally