TerrainFactoryTest - UQcsse3200/2023-studio-3 GitHub Wiki
Test Plan for TerrainFactoryTest Class
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
ResourceServiceto retrieve the necessary textures.
Methodology:
- Setup (BeforeEach):
- Mock essential components like
CameraComponent,OrthogonalTiledMapRenderer,ResourceService, andTexture. - Configure the
ServiceLocatorto use the mockedResourceService. - Initialize the
TerrainFactoryusing a spy to enable stubbing and verification.
- Mock essential components like
Test Case: testCreateTerrainGeneral**
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
TerrainFactoryto create a specific terrain type, in this case,TerrainFactory.TerrainType.ALL_DEMO.
- Use
-
Assertions:
- Confirm that the created
TerrainComponentis 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
BeforeEachmethod. - External components such as
CameraComponent,OrthogonalTiledMapRenderer, andResourceServiceare 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.