Inventory Unit Testing - UQdeco2800/2022-studio-2 GitHub Wiki

Introduction

In this section, the unit testing is explained for the following unit tests. This code comes from the file called InventoryComponentTest

Test Code

Each Test will begin with the following code

image

Below are tests to check if the inventory can be created, hold an item, and have its index gotten. These are primary functions in order for an inventory to work, thus they are performed first

image

After the inventory is found to work without crashing, tests are done to check if an item can be added to the inventory, or any items can be sorted. These are important functions to test for once the inventory begins to be used

image

Now that items can be added to the inventory, they must also be able to be removed. In addition to this, they must also be able to check their own quantity so that if multiple of the same type of item are picked up, then that same items can be checked as being on the same slot. image

Now that items are able to be added and removed and checked for quantity, the items must be able to be used, thus the functions involved with equipping and unequipping the items are checked, as well as checking that they affect the player once equipped.

image

image

Since some items will be moved to the quickbar before being used, such as potions, these features must be checked to work before potions can be used.

image

Now that the quickbar has been checked to work properly, the process of consuming potions must be checked. This involved seeing that the program gets the potions index so the correct potion can be used in the order that it was added to the quickbar as well as removing the potion once it is used and finally applying the effect of that potion on the player.

image

image

Author: Lachlan McDonald 45320932 (@Lukeyone) Discord: merty009 #1029