-
Notifications
You must be signed in to change notification settings - Fork 4
TNTTowerCombatTask Test Plan
Ensuring that our game operates reliably requires exhaustive testing of the components that comprise its entities. The TNTTowerCombatTask
class, responsible for managing the behavior and actions of our TNT Towers, is no exception. This document outlines the test plan that focuses on validating its Finite State Machine (FSM) based architecture and behavior, primarily concentrating on the updateTowerState()
method.
The aim of this test plan is to validate:
- The proper state transition within
updateTowerState()
. - The accurate triggering of events corresponding to each state.
- The effectiveness of methods such as
isTargetVisible()
in state transition.
- Mock the
GameTime
service and register it withServiceLocator
. - Register a new
PhysicsService
andEntityService
with theServiceLocator
. - Initialize a
TNTTowerCombatTask
instance.
Objective: To confirm that invoking start()
triggers the default event.
Steps:
- Create a mock TNT entity and a mock EventListener0 for the default event.
- Start the
TNTTowerCombatTask
and verify that the default event gets triggered.
Objective: To confirm that state transitions and event triggers work as expected when a target is within range.
Steps:
- Create mock TNT and NPC entities and position them within range.
- Add mock EventListeners for dig, explode, and damage events.
- Update the
PhysicsService
and entities. - Check if the TNT is in the correct state and the appropriate events are triggered.
Objective: To validate that the tower stays in the IDLE state when no target is in range.
Steps:
- Create mock TNT and NPC entities and position them out of range.
- Update the
PhysicsService
and entities. - Confirm that the state remains at IDLE and no unnecessary interactions occur.
- Classes such as
ServiceLocator
,CombatStatsComponent
,PhysicsComponent
, andHitboxComponent
are properly implemented and previously tested. - External libraries like Mockito and JUnit function as expected.
The test code uses JUnit and Mockito for testing. It sets up the environment, mocks the necessary components, and verifies the expected behavior for each test case.
This test plan and accompanying test code provide a comprehensive methodology to validate that the TNTTowerCombatTask
class and its updateTowerState()
method function as expected.