-
Notifications
You must be signed in to change notification settings - Fork 4
TerrainFactoryTest
Mohamad Dabboussi edited this page Oct 2, 2023
·
1 revision
Introduction:
The TerrainFactoryTest
class aims to validate the functionality of the TerrainFactory
class which is responsible for generating various terrains in the game. This document provides an in-depth test plan for the aforementioned test class.
Objective:
To verify that the TerrainFactory
class:
- Properly creates a terrain type with accurate configurations.
- Interfaces correctly with the
ResourceService
to retrieve the necessary textures.
Methodology:
-
Setup (BeforeEach):
- Mock essential components like
CameraComponent
,OrthogonalTiledMapRenderer
,ResourceService
, andTexture
. - Configure the
ServiceLocator
to use the mockedResourceService
. - Initialize the
TerrainFactory
using a spy to enable stubbing and verification.
- Mock essential components like
Objective:
To verify that TerrainFactory
accurately creates the specified terrain type with the correct configurations.
Steps:
-
Texture Retrieval Setup:
- Mock the texture retrieval from
ResourceService
.
- Mock the texture retrieval from
-
Terrain Creation:
- Use
TerrainFactory
to create a specific terrain type, in this case,TerrainFactory.TerrainType.ALL_DEMO
.
- Use
-
Assertions:
- Confirm that the created
TerrainComponent
is not null. - Check the height and width configurations of the terrain. The height should represent the number of lanes, while the width should represent the number of tiles per lane.
- Confirm that the created
Expected Outcome:
When creating a terrain of type ALL_DEMO
, the resulting terrain should have 6 lanes and 20 tiles per lane.
Assumptions:
- All required mock setups for the tests have been established in the
BeforeEach
method. - External components such as
CameraComponent
,OrthogonalTiledMapRenderer
, andResourceService
are expected to work as per their specified functionality when interacting withTerrainFactory
.
Potential Challenges:
-
Texture Retrieval: If there are any changes to the way textures are fetched from
ResourceService
, the test may need adjustments. - Terrain Configurations: Any changes in the terrain configurations for a specific type, like the number of lanes or tiles, would necessitate corresponding changes in the test.