Skip to content

FollowComponent Test Plan

gaurikadiwan edited this page Oct 5, 2023 · 1 revision

Overview

The CompanionFollowComponent plays a crucial role in managing the behaviour of companion entity in the game. These companions are designed to follow and interact with the player character, contributing to the immersive gameplay experience. Creating a testing plan for the FollowComponent class involves identifying the key functionalities and behaviours that need to be tested to ensure the component works as expected.

Mock Objects:

Entity (Mock): Simulates an entity for testing interactions.

PlayerCharacter (Mock): Represents the player character for interaction testing.

CompanionFollowComponent (Actual): The component under test.

The CompanionFollowComponent will be initialised with mock objects for testing purposes.

Test Cases

Mock the position of the player character to be at coordinates (0, 0). when(playerCharacter.getPosition()).thenReturn(new Vector2(0, 0));

Assert that the companion entity's position has changed towards the player character. verify(entity).setPosition(any(Vector2.class));

Assert that the companion entity's position has changed away from the player character. verify(entity).setPosition(any(Vector2.class));

Mock the player character's actions to simulate player interaction. when(playerCharacter.isInteracting()).thenReturn(true);

Conclusion

This test plan covers essential scenarios for testing the CompanionFollowComponent. By simulating player and companion interactions, we verify that companions correctly follow or repel from the player character. These tests ensure that the component behaves as expected, contributing to a dynamic and engaging gameplay.

Clone this wiki locally