Config Loader Test Plan - UQcsse3200/2023-studio-2 GitHub Wiki
These tests are for the ConfigLoader
class, which handles loading of game areas from config files. As the config loader has extremely high coverage, mock based testing is used to fake the underlying requirements. The ConfigLoader produces state, which is compared to expected state (handwritten) by assertion testing.
The config loader
Setup
To test the config loader, the following static classes had to be mocked:
- LoadUtils
- FileLoader
Additionally, before each test, several variables needed to be set up to define expected config files used for mocking.
Teardown
utilsMock and fileLoaderMock need to be closed as they are mocking static classes, to avoid leakage.
Tests
loadNewValidGame()
- Attempts to load a non-existent game (therefore using the default game) successfully
loadSavedGameFiles()
- Attempts to load a saved game that uses all components from the save directory successfully
loadInvalidGameFile()
- Attempts to load an invalid game file and throws the correct error
loadInvalidGamestateFile()
- Attempts to load an invalid game (due to an invalid gamestate) and throws the correct error
loadInvalidGameAssetsFile()
- Attempts to load an invalid game (due to an invalid assets file) and throws the correct error
loadSavedGameFileWhenExists()
- Attempts to load a valid game file when the rest of the files are not saved.
loadSavedGameStateWhenExists()
- Attempts to load a valid gamestate when the rest of the files are not saved.
- Attempts to load a valid assets when the rest of the files are not saved.
- Attempts to load a valid gamestate when the rest of the files are not saved.
loadNewLevel()
- Attempts to load a non-existent level (therefore using the default level) successfully. This test loads a mocked test level and not production levels.
loadSavedLevel()
- Attempts to load a saved level successfully.-
loadInvalidSaveLevel()
- Attempts to load an invalid saved level and throws the correct error
- Attempts to load a saved level successfully.-
loadInvalidLevel()
- Attempts to load a non-existent level (therefore using the default level) successfully. This test loads a mocked test level and not production levels.
loadInvalidSavedLevel()
- Attempts to load a saved level successfully.
loadValidNewMapDirectory()
- Attempts to load a valid map directory with the correct error.
- Note: not able to be tested as we were unable to mock the ConfigLoader.loadEntities.
loadInvalidNewMapDirectory()
- Attempts to load an invalid map directory with the correct error.
- Note: not able to be tested as we were unable to mock the ConfigLoader.loadEntities.
LoadValidSaveMapDirectory()
- Attempts to load a valid saved map directory successfully.
LoadSaveMapDirectoryInvalidFile()
- Attempts to load an invalid saved map directory (due to an invalid file) with the correct error.
LoadSaveMapDirectoryInvalidFile()
- Attempts to load an invalid saved map directory (due to an invalid entities file) with the correct error.
loadEntityFromFolder()
- Attempts to load an entity from a folder correctly
- Note: not able to be tested as we were unable to mock Gdx.files correctly
loadEntitiesFromFolder()
- Attempts to load multiple entities correctly
- Note: not able to be tested as we were unable to mock Gdx.files correctly
loadInvalidEntityFromFolder()
- Attempts to load an invalid entity from a folder with the correct error.
- Note: not able to be tested as we were unable to mock Gdx.files correctly
loadValidConfigFile()
- Attempts to load a valid config file of arbitrary output class and ensure valid output.
loadInvalidConfigFile()
- Attempts to load a invalid config file of arbitrary output class and throw InvalidConfigException.
loadProductionGame()
- Attempts to load the production (not mocked) game fully, not performing assertion testing, but verifying there are no errors or invalid state. This will ensure that a failing production game cannot be committed to main.