Skip to content

Team 1 Testing Plan Sprint 2

aA-86 edited this page Sep 15, 2021 · 40 revisions

Introduction

Team 1 was tasked with the creation buffs and de-buff items. When the player comes into contact with these items the player stats will change temporarily in response to the type of item. For example, a speedBoost item will increase the player's speed stat by a constant amount and will last a predetermined duration before the player's speed stat returns to normal. In order to effectively test these operations, JUnit tests will be used to validate the chain of method calls and return values. The class that was test was the StatusEffectOperation class.

StatusEffectTest

Mocking

Mocking was used to remedy issues that arose due to the high coupling between StatusEffectOperation with the Entity and PlayerActions class. One of these issues is highlighted below, where the method call for the Entity object, player, returns null.

Entity player = new Entity();
player.getComponent(PlayerActions.class); // returns null
player.getComponent(PlayerActions.class).getSpeed(); // evaluates as null.getSpeed()

As can be seen above, the Entity object wants to call its respective PlayerActions component, however, the class is not instantiated and thus, the process of retrieving the player's speed is unreachable through calling the methods natively. To rectify this, the player is mocked to allow the tester to redefine the method calls for a testing environment.

Entity player = Mockito.mock(Entity.class)

Method calls can be redefined using the following syntax:

when(CLASS.FUNCTION(PARAMETERS)).thenReturns(RETURN_VALUE)

Using the above syntax, the following functions for the player object is defined:

private PlayerActions playerActions = new PlayerActions();
private omponentStatsComponent combatStatsComponentNotDead = new private CombatStatsComponent(1, 0);
private ComponentStatsComponent combatStatsComponentIsDead = new CombatStatsComponent(0, 0);

@Test
public void testSpeedBuffIsDead() {
when(player.getComponent(PlayerActions.class)).thenReturn(playerActions);
when(player.getComponent(CombatStatsComponent.class)).thenReturn(combatStatsComponentNotDead); // alternatively, return combatStatsComponentIsDead

/* test code */
} 

The above definition returns the PlayerActions object, playerActions, to the player whenever .getComponent(PlayerActions.class) is called. As such, this will not result in the null issue highlight previously. The same reason applies to .getComponent(CombatStatsComponent.class).

Overwriting Functions

As a direct result of mocking class and redefining the behaviour of their methods, the methods in StatusEffectOperation objects must also be changed in order to reflect this. Largely, this means removing code that is not relevant to the test; such as triggering events, private method calls and, explicitly link the player with its PlayerActions and CombatStatsComponent objects. When overwriting the function, care has been made in order to reflect the native call order of each function. The general syntax can be seen below for speedChange():

StatusEffectOperation speedBoost = new StatusEffectOperation() {
@Override
public int speedChange() {/* overwritten code */}

};

JUnit Tests

JUnit tests were written for each of the implemented buff and de-buffs. These were, at the time of writing, SpeedBuff, SpeedDebuff, JumpBuff and StuckInTheMud. The corresponding methods for the stat alteration in StatusEffectOperation were the focus of testing.

SpeedBuff/SpeedDebuff

Buffs and de-buffs have two states of termination, asynchronous termination through its duration time and, through player death. These tests are split into two JUnit tests, however, they are largely the same. The first test is to test the speedBuff if the player is not dead. In such a case, we first test if the player's current speed, prior to the speedBuff, is as expected. This is done through multiple assertion tests as follows:

float expected = 10;
float result =  player.getComponent(PlayerActions.class).getSpeed();
assertEquals(expected, result);
assertTrue(result == expected);
assertFalse(result != expected);
assertNotEquals(expected + 1, result);

Subsequently, the method to add the speedBuff is called. The change in stat is recorded and compared to the expected value.

type = 1;
float expected = 5;
float result = speedBoost.speedChange(type); // This changes the speed stat of the player by the amount of the speed buff. .speedChange() returns the difference between the new speed and the original speed. 

Table of Contents

Home


Game Design

Game Design Document

Void/Antivirus

Loading Screen

Game Sound

Menu Assets

Player Design

     Original Design

     Final Design


Gameplay

Movement

Jumping & Sliding

Jump Pads

Portals & Bridges

Buttons

Pick-Ups

Physics

    Momentum & Physics

    Gravity

    Collision


Level Design

Level 1

     Background

     Textures

     Map Design

Level 2

     Background

     Textures

     Map Design

Level 3

     Background

     Textures

     Map Design

Level 4

     Background

     Textures

     Map Design


Sprint Round-Up

Sprint 1 Summary

Sprint 2 Summary

Sprint 3 Summary

Sprint 4 Summary


User Testing

Testing Plans

Sprint 1

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

Sprint 2

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

Sprint 3

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

Sprint 4

     Team 1
     Team 2
     Team 3
     Team 4
     Team 5

User Testing

Sprint 1

     Sprint 1 - Game Audio
     Sprint 1 - Character Design
     Sprint 1 - Menu Assets
     Sprint 1 - Map Design
     Sprint 1 - Void

Sprint 2

     Sprint 2 - Game Audio
     Sprint 2 - Character Design
     Sprint 2 - Menu Assets
     Sprint 2 - Interactable Design Animation
     Sprint 2 - Levels 1 & 4, and Level Editor
     Sprint 2 - Proposed Level 2 & 3 Designs
     Sprint 2 - Current Game State

Sprint 3

     Sprint 3 - Menu Assets
     Sprint 3 - Map Design
     Sprint 3 - Score Display
     Sprint 3 - Player Death and Spawn Animations
     Sprint 3 - Pick Ups and Pause Screen

Sprint 4

     Sprint 4 - Gameplay
     Sprint 4 - Game UI and Animation
     Sprint 4 - Level Background and Music
     Sprint 4 - Game User Testing
     Sprint 4 - Final Game State Testing


Game Engine

Entities and Components

     Status Components
     Event System
     Player Animations Implementation

Level Editor

Level Saving and Loading

Status Effect


Defunct

Development Resources

    Getting Started

Entities and Components

    Level Editor (Saving and Loading
         Multiple Levels)

    Service Locator

    Loading Resources

    Logging

    Unit Testing

    Debug Terminal

Input Handling

    UI

    Level Saving/Loading

    Status Effects

    Animations

    Audio

    AI

    Physics

Game Screens and Areas

    Terrain

    Concurrency & Threading

    Settings


Troubleshooting

MacOS Setup Guide

Clone this wiki locally