Multiple maps testing plan - UQdeco2800/2021-ext-studio-2 GitHub Wiki
Rocks and woods testing
Testing the SpawnRock() and SpawnWoods(), whether the rocks and woods can be generated successfully.
@Test
void shouldSpawnRock() {
GameArea gameArea =
new GameArea() {
@Override
public void create() {
}
};
ServiceLocator.registerPhysicsService(new PhysicsService());
ServiceLocator.registerEntityService(new EntityService());
ServiceLocator.registerRenderService(new RenderService());
ResourceService resourceService = new ResourceService();
resourceService.loadTextures(forestTextures);
resourceService.loadAll();
ServiceLocator.registerResourceService(resourceService);
Entity rockMock = mock(ObstacleFactory.createRock().getClass());
gameArea.spawnEntity(rockMock);
verify(rockMock).create();
gameArea.dispose();
verify(rockMock).dispose();
}
@Test
void shouldSpawnWoods() {
GameArea gameArea =
new GameArea() {
@Override
public void create() {}
};
ServiceLocator.registerPhysicsService(new PhysicsService());
ServiceLocator.registerEntityService(new EntityService());
ServiceLocator.registerRenderService(new RenderService());
ResourceService resourceService = new ResourceService();
resourceService.loadTextures(forestTextures);
resourceService.loadAll();
ServiceLocator.registerResourceService(resourceService);
Entity woodMock = mock(ObstacleFactory.createWood().getClass());
gameArea.spawnEntity(woodMock);
verify(woodMock).create();
gameArea.dispose();
verify(woodMock).dispose();
}
@Override
public void create() {
}
Things that could not be tested
As most of our features are UI related, so most of them can be tested by the Junit test. For example, the Background image and invisible ceiling can all be tested by running the game UI.