Test Plan for Sensor Component - UQcsse3200/2024-studio-3 GitHub Wiki
Test Environment
- Framework: JUnit 4
- Objects Used: SensorComponent, InteractionComponent, Entity (mocked), Interactable Target (mocked), non-Interactable Target (mocked)
Test Cases - Testing SensorComponent Methods
-
Sensor Component Initialisation: To verify that the SensorComponent is properly initialized and its interaction component is correctly set up. Purpose: To ensure that the sensor component handles its creation and sets the correct target layer. Expected Results: Sensor Component, it's Interaction Components, and its fixture is not null after creation The fixture should be the same as the entity created fixture
-
Entity Initialisation: To verify that the entity is correctly initialized with the InteractionComponent and that its fixture is properly configured. Purpose: To ensure that testing of other components are not affected by incorrect initialisation.layer. Expected Results: It's fixture for the interaction component should not be null The fixture should be a part of the
INTERACTABLE
physics layer -
Target Initialisation: To verify that the entity is correctly initialised with the InteractionComponent and that its fixture is properly configured. Purpose: To ensure that testing of other components are not affected by incorrect initialisation. Expected Results: It's fixture for the interaction component should not be null The fixture should be a part of the
INTERACTABLE
physics layer -
Adding Features to a List: To verify that when an interactable component is collided with, it is added to a list. Purpose: To ensure that interactable objects are being handled correctly when collided with. This involves adding it to a list of colliding objects Expected Results: Before colliding with an interactable object, the closest interactable object should be null After colliding with an interactable object within range, there should be 1 value inside the colliding fixtures variable
-
Detecting closest object: To verify that the closest interactable object is returned when calling
getClosestFixture()
. Purpose: To ensure that the closest interactable object is always returned regardless of the number of interactable objects close by Expected Results: After colliding with an interactable object, the closest interactable object should not null After colliding with an interactable object, the closest interactable object should be the collided interactable object -
Not detecting far objects: To verify that objects out of range are not able to be interacted with. Purpose: To ensure that if an interactable object is out of range of the sensor component, it is not added to the list of interactable objects and thus cannot be interacted with. Expected Results: After colliding with an object out of range, the closest interactable object should be null
-
Not detecting a bad target: To verify that only interactable objects are detected by the sensor. Purpose: To ensure that the player can not call interactable functions on an object that is unable to be interacted with. Expected Results: After colliding with an non-interactable object, the closest interactable object should be null
-
Remove a target after the collision has ended: To verify that after the player is out of range of an object and has thus called to end the collision, it can no longer be interacted with. Purpose, if the player is out of range of a previously interactable object, they should not be able to interact with it. Expected Outcome: After calling collision ended on the only interactable object within range, the closest interactable object should be null