Skip to content

Player Death Testing Plan

racheljadel edited this page Oct 1, 2023 · 4 revisions

Introduction:

Player Death is an integral aspect of the game's function, and the implementation of a death screen was important to communicate to the user that the player has died and give them the option to either respawn or exit to the main menu. To improve the implementation of player death, a death animation was added. Therefore, these implementations must be adequately tested, and so PlayerDeathScreen and the player death animation were tested in accordance with the following testing plan:

Test Plan for PlayerDeathScreen

Objective:

To validate that the death screen pops up once the player dies, by ensuring the death screen is displayed once the player's health reaches zero, after waiting 750ms (which allows time for the death animation to play).

Methodology:

Test Case 1: DeathBackgroundThreeLives

Objective: To validate the death screen showing up once the player's health reaches zero.

Steps:

  1. Mock a GdxGame.
  2. Create Player entity, and add the CombatStatsComponent with the default player stats.
  3. Set player health to zero, to trigger the PlayerDeathScreen that shows there are three lives remaining.
  4. Wait 4 seconds, to allow time for the death animation to play.
  5. Assert that the screen currently being displayed is the correct PlayerDeathScreen.

Test Case 2: DeathBackgroundTwoLives

Objective: To validate the death screen showing up once the player's health reaches zero.

Steps:

  1. Mock a GdxGame.
  2. Create Player entity, and add the CombatStatsComponent with the default player stats.
  3. Set player health to zero, to trigger the PlayerDeathScreen that shows there are two lives remaining.
  4. Wait 4 seconds, to allow time for the death animation to play.
  5. Assert that the screen currently being displayed is the correct PlayerDeathScreen.

Test Case 3: DeathBackgroundOneLife

Objective: To validate the death screen showing up once the player's health reaches zero.

Steps:

  1. Mock a GdxGame.
  2. Create Player entity, and add the CombatStatsComponent with the default player stats.
  3. Set player health to zero, to trigger the PlayerDeathScreen that shows there are one life remaining.
  4. Wait 4 seconds, to allow time for the death animation to play.
  5. Assert that the screen currently being displayed is the correct PlayerDeathScreen.

Test Case 4: DeathBackgroundZeroLives

Objective: To validate the death screen showing up once the player's health reaches zero.

Steps:

  1. Mock a GdxGame.
  2. Create Player entity, and add the CombatStatsComponent with the default player stats.
  3. Set player health to zero, to trigger the PlayerDeathScreen that shows there are zero lives remaining.
  4. Wait 4 seconds, to allow time for the death animation to play.
  5. Assert that the screen currently being displayed is the correct PlayerDeathScreen.

Evidence

@Test
    void testDeathBackgroundThreeLives() {
        GdxGame game = mock(GdxGame.class);
        Entity player = new Entity();
        player.setEntityType("player");
        player.addComponent(new CombatStatsComponent(0, 10, 10, false, 3));
        final Timer timer = new Timer();
        java.util.TimerTask testScreen = new java.util.TimerTask() {
            @Override
            public void run() {
                assertEquals(PLAYER_DEATH_3, game.getScreenType());
                timer.cancel();
                timer.purge();
            }
        };
        timer.schedule(testScreen, 4000);
    }

Test Plan for Player Death Animation and Death Screen

Objective:

To validate that the death animation of the player is shown when the player's health reaches 0. Also validates the death screen showing up 750 ms later. This is to ensure:

  • The death animation is displayed once the player's health reaches zero.
  • The death animation is completed before the death screen pops up.
  • The death of the player shows all 5 frames of the animation.
  • The death screen displays the two options of either respawning or exiting to the main menu.

Methodology:

Since the death animation is a visual component, the best way to test its function is to provide a video of the animation. This video can also be used to test the display of the death screen. The following video provides this visual test: https://youtu.be/_UwFg-BYXFY

Clone this wiki locally