Skip to content

GameMap Test Plan

HunterWhitty edited this page Oct 3, 2023 · 4 revisions

The GameMap class can be tested by both playtesting and JUnit tests. Using the createTestTerrainComponent method instead of the createTerrainComponent methods in the spawnTerrain method in the SpaceGameArea class can be used to load different maps into the actual game itself. This can be used to test how different tiles spawn and how the composition of tiles appears.

Both the createTerrainComponent and createTestTerrainComponent methods are tested like this, using visual confirmation of the map layout to confirm that the map spawned correctly. This is because JUnit tests often lack all of the components necessary to create a TerrainComponent necessary for not just the terrain rendering but for the map loading. More on this and GameMap testing here.

Most of the other methods in the GameMap class are tested using JUnit tests. This process is also explained here. The loadTestTerrain method was used instead of the createTestTerrainComponent method. This is because both methods successfully instantiate the required TiledMap of the map, but the first method does not create a TerrainComponent. A mock TerrainComponent is created in the JUnit testing to allow for the getTile and conversion methods to work.

Clone this wiki locally