-
Notifications
You must be signed in to change notification settings - Fork 4
TowerFactory Test Plan
The TowerFactory is the main hub of towers that creates all the defensive towers in the game. All different tower Entities produced by TowerFactory are made using respective methods that use the base Entity created by createBaseTower
method. Once the base entity is created, all the different components are added which provide towers with character and necessary properties. This documentation aims to outline a detailed test plan for this class, mainly testing for the added components to the created Entities.
The primary objectives of this test plan are:
- To verify if the components are added successfully to the Entities.
- To check component values for the added components.
All the relevant files are loaded in a dictionary which is further loaded by the relevant components.
- Mock the GameTime and register is using the ServiceLocator.
- Initialise and register new instances of
PhysicsService
,RenderService
andResourceService
using ServiceLocator. - Load the relevant sound, texture and atlas files using the
ResourceService
loaded earlier - Create new instances of all the towers that will be created using this TowerFactory.
Objective: To confirm that the towers created using createBaseTower
are actually entities and are not NULL
Steps:
- Check if the instances created in the setup are not equal to NULL using
asserNotNull()
Objective: To check if the created base Entity has the ColliderComponent
Steps:
- Access the ColiderComponent of each tower using
getComponent()
method for entities and check if they are not equal to NULL
Objective: To check if the created base Entity has the HitBoxComponent
Steps:
- Access the HitBoxComponent of each tower using
getComponent()
method for entities and check if they are not equal to NULL
Objective: To check if the created base Entity has the PhysicsComponent
Steps:
- Access the PhysicsComponent of each tower using
getComponent()
method for entities and check if they are not equal to NULL
Objective: To check if the created Entity contains the correct values for health, attack and cost of the tower.
Steps:
- Access the health of the tower using
getComponent()
for CombatStatsComponent and then access the attribute health. Further check if the output value matches the expected value. - In order to check for the attack attribute follow step 1 of this test and replace the attribute name with attack and check if the output values matches the expected value.
- To check the cost of the tower, use the
getComponents()
method to access the CostComponent and check with the desired value. - Repeat the above 3 steps for all the tower instances.
Objective: To check if the created base Entity has the AnimationComponent
Steps:
- Access the AnimationComponent of each tower using
getComponent()
method for entities and check if it is not equal to NULL. - Repeat the above step for all the instantiated towers.
- Methods like
getComponent()
function properly and are already tested before. - All the externally added libraries (eg mockito) 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.