Skip to content

TerrainFactoryTest

Mohamad Dabboussi edited this page Oct 2, 2023 · 1 revision

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 ResourceService to retrieve the necessary textures.

Methodology:

  • Setup (BeforeEach):
    1. Mock essential components like CameraComponent, OrthogonalTiledMapRenderer, ResourceService, and Texture.
    2. Configure the ServiceLocator to use the mocked ResourceService.
    3. Initialize the TerrainFactory using a spy to enable stubbing and verification.

Test Case: testCreateTerrainGeneral**

Objective: To verify that TerrainFactory accurately creates the specified terrain type with the correct configurations.

Steps:

  1. Texture Retrieval Setup:

    • Mock the texture retrieval from ResourceService.
  2. Terrain Creation:

    • Use TerrainFactory to create a specific terrain type, in this case, TerrainFactory.TerrainType.ALL_DEMO.
  3. 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.

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, and ResourceService are expected to work as per their specified functionality when interacting with TerrainFactory.

Potential Challenges:

  1. Texture Retrieval: If there are any changes to the way textures are fetched from ResourceService, the test may need adjustments.
  2. 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.
Clone this wiki locally