-
Notifications
You must be signed in to change notification settings - Fork 7
GameMap Test Plan
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 in 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.
To test the GameMap
class, a dummy 4x4 map (constructed using a TiledMapTileLayer
) was used. It was then populated with 16 tiles in a certain order.
The main focus of the tests were on the getTile
, vectorToTileCoordinates
, tileCoordinatesToVector
, getTraversableTileCoordinates
and getNonTraversableTileCoordinates
methods.
To test the getTile
method, 9 tests were made to test if the getTile method worked on the edge tiles of the map, the edge rows of tiles of the map and the internal tiles of the map (the ones which are not in any of the edge rows). This tests that getTile method works anywhere on a given map.
For the vectorToTileCoordinates
method one test was made which tested the conversion of all possible Vectors on the map to Gridpoints.
For the tileCoordinatesToVector
method one test was made which tested the conversion of all possible Gridpoints (tile x, y positions) on the map to Vectors.
For the getTraversableTileCoordinates
method, two tests were made. One tested to ensure that all of the traversable tile coordinates were included in the returned Array List and the other tested to ensure that none of the non-traversable tile coordinated were included in the returned Array List.
For the getNonTraversableTileCoordinates
method, two tests were made. One tested to ensure that all of the non-traversable tile coordinates were included in the returned Array List and the other tested to ensure that none of the traversable tile coordinated were included in the returned Array List.