Skip to content

Testing the interactable components

Pranay Premdas edited this page Sep 15, 2021 · 5 revisions

Testing the interactable components listeners

Initial Testing for listeners
Initially to test if the listeners were functioning as indented, the Mockito framework was used to mock the listener0 class. In addition, a create bed method similar to the one used in the game was also implemented to replicate the process. However, an issue encountered with this approach was determining a way to verify that the listener did detect a collision after triggering the "start_collision" event. After multiple attempts it was determined that the only way to verify that the listener was working was to use the same listener and bed instance. This however, would require restructuring the main classes to implement methods that get the listener instance. However, given the way a listener was added to the object, it is difficult to obtain the instance without disrupting the overall functionality of the game. Therefore, an alternative method of testing was made (Explained below).

Current Testing for listeners
A way to test if the interaction is being successfully registered, a Logger is implemented in each interactable component class. When playing the game, on each interaction a Logger message will be printed to the output.

Example of logger message for door -
When the player is near the door: DOOR started collision with PLAYER, highlighting door
When the player walks away from the door: DOOR ended collision with PLAYER, un-highlighting door
When the player is near the door and interact key is pressed: DOOR started collision with SURVEYOR, triggering door animation

Similarly a message for the bed and TV will be printed.

Clone this wiki locally