Sprint 4 terrain test - UQdeco2800/2021-ext-studio-2 GitHub Wiki

Magma and nails test

Testing the SpawnMagma() and SpawnNails(), whether the magma and nails can be generated successfully.

@Test
    void shouldSpawnMagma() {

        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 MagmaMock = mock(ObstacleFactory.createWood().getClass());

        gameArea.spawnEntity(MagmaMock);
        verify(MagmaMock).create();

        gameArea.dispose();
        verify(MagmaMock).dispose();
    }

    @Test
    void shouldSpawnNails() {

        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 NailsMock = mock(ObstacleFactory.createWood().getClass());

        gameArea.spawnEntity(NailsMock);
        verify(NailsMock).create();

        gameArea.dispose();
        verify(NailsMock).dispose();
    }

Testings for UI

  1. Checkout the attack values while playing the game
  2. User testings for the terrain layout and check whether the player will be stuck between the rocks and woods
  3. Check the game over screen while the character is dead