-
Notifications
You must be signed in to change notification settings - Fork 4
EngineerCombatTask Test Plan
The EngineerCombatTask
class is a crucial component of the game mechanics, enabling engineers to shoot and detect enemy mobs. This class implements various states in the Engineer entity to help it perform a firing routine and switches through them based on enemy presence near the engineer.
- To verify that the state machine switches correctly through idle and firing states.
- To verify that the correct animation triggers are launched when switching states.
- To verify that the engineer is able to shoot projectiles towards enemy mobs.
- Mock the
GameTime
service and register it usingServiceLocator
. - Initialize and register new instances of
PhysicsService
andEntityService
withServiceLocator
. - Load sounds and animation images (Texture atlases) for the engineer entity.
- Create a new
EngineerCombatTask
and a mock engineer entity. - Add the
EngineerCombatTask
to the engineer'sAITaskComponent
and set it as theTaskRunner
.
Objective: To confirm that invoking start()
triggers the idleStart
event.
Steps:
- Add a listener to the mock engineer for the
IdleStart
event. - Start the
EngineerCombatTask
. - Update game physics.
- Verify the event call.
Objective: To confirm that the Engineer enters the FIRING
state when detecting one or more enemies.
Steps:
- Create a mock attacker entity with a
PhysicsLayer
of 3. - Add a listener to the mock engineer for the
firingSingleStart
event. - Place the attacker beside the engineer and Start the
EngineerCombatTask
. - Update game physics.
- Verify the event call.
Objective: To verify that the Engineer switches back to the IDLE_RIGHT
state after a mob isn't visible anymore.
Steps:
- Create a mock attacker entity with a
PhysicsLayer
of 3. - Place the attacker beside the engineer and Start the
EngineerCombatTask
. - Update game physics so the Engineer detects the attacker and switches to firing state.
- Delete the attacker using
dispose()
and add a listeneridleStart
to engineer. - Update game physics so the engineer switches to the idle state.
- Ensure that the target is not visible, then verify that
idleStart
was triggered, otherwise fail.
Objective: To verify that the Engineer spawns a projectile entity during the FIRING
state.
Steps:
- Create a mock attacker entity with a
PhysicsLayer
of 3. - Add a listener to the mock engineer for the
engineerProjectileFired
event. - Place the attacker beside the engineer and Start the
EngineerCombatTask
. - Update game physics.
- Verify the event call.
- 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.