-
Notifications
You must be signed in to change notification settings - Fork 4
DroidCombatTask Test Plan
The DroidCombatTask
class is a crucial component in our game's architecture, responsible for determining the behavior and actions of the Droid Towers in the game environment. The class operates based on a Finite State Machine (FSM) and employs various states to guide the tower's actions. This document aims to outline a detailed test plan for this class, focusing primarily on the updateTowerState()
method and its underlying functionalities.
The primary objectives of this test plan are:
- To verify correct state transitions within
updateTowerState()
. - To ensure the accurate triggering of events in accordance with each state.
- To test the effectiveness of utility methods like
isTargetVisible()
in the state transition logic.
- Mock the
GameTime
service and register it usingServiceLocator
. - Initialize and register new instances of
PhysicsService
andEntityService
withServiceLocator
. - Instantiate a
DroidCombatTask
object for testing.
Objective: To confirm that invoking start()
triggers the WALK
event.
Steps:
- Create a mock Droid entity and a mock
EventListener0
for theWALK
event. - Invoke
start()
method on theDroidCombatTask
instance. - Verify that the
WALK
event is triggered.
Objective: To confirm correct state transitions and event triggers when a target is within the defined range.
Steps:
- Create mock Droid and NPC entities and position them within the defined range.
- Attach mock
EventListener0
s for theATTACK_UP
,ATTACK_DOWN
,SHOOT_UP
, andSHOOT_DOWN
events. - Update the
PhysicsService
and the Droid entity. - Assert that the Droid transitions through states as expected and that the appropriate events are triggered.
Objective: To verify that the Droid stays in the IDLE
state when no target is in range.
Steps:
- Create mock Droid and NPC entities and position them out of range.
- Attach mock
EventListener0
for theIDLE
event. - Update the
PhysicsService
and the Droid entity. - Assert that the Droid remains in the
IDLE
state and no other events are triggered.
- Classes like
ServiceLocator
,CombatStatsComponent
,PhysicsComponent
, andHitboxComponent
are properly implemented and have been previously tested. - External libraries such as Mockito and JUnit are functioning as expected.
The test code leverages JUnit and Mockito frameworks to set up the testing environment, mock necessary components, and verify the expected behavior for each test case.