Monday, 4 January 2016

Black and White Box Testing for my Prototype Game

Throughout the creation of my game I have performed a variety of methods for testing the game to see if it works as intended, and this involves both Black Box Testing (for functionality and seeing if everything works as intended) and White Box Testing (for the code's structure). Because I have so much functionality included in the game, as talked about in the development blog posts, there's a lot of testing and debugging involved in the game-making process to ensure everything is of a high-quality. These two methods work together to test the game from both the player's perspective to make sure they essentially are playing a working product with blackbox testing, whereas the whitebox testing organises everything 'behind the scenes' that is never normally seen in-game.

First I will talk about my Black Box Testing, which is designed for me to test if the game functions correctly throughout development and is constantly updated throughout the creation of my game (compared to White Box Testing which is performed when the code is finished), and this ensures each mechanic works as intended before I move on to including the next one. It doesn't really look at the code as a whole, rather the actions the code actually does. Here is my Black Box test-log I made for my own Unity game, that has been continuously updated and dated (with the date each post was typed) throughout the development of my game:

Black box test-log:

Date

Test No
Purpose of testing

Input

Expected output

Actual output

Additional comments

27/11/15
B1.1
Can the player make the bird perform an action depending on the key pressed?
Left arrow key
The bird should walk to the left and play the walking animation
The bird moves to the left and plays the animation
The bird has no friction unless the ground material object is applied to the trigger box of the ground object, as that contains the friction for movement

B1.2

Right arrow key
The bird should walk to the right and play the walking animation
The bird moves to the right and plays the animation
(See screenshot in player input blog post for photo evidence.)

B1.3

Stop pressing an arrow key
The bird slows down gradually and then stops, then plays the idle animation.
The bird slows down and plays the idle animation when it has fully stopped moving
The friction causes the bird to slightly slide forwards before it stops fully

B1.4

Spacebar
The bird should jump and play the jump animation, if the player presses spacebar again before you land perform a double jump
The bird is able to jump, double jump and play the jumping animation, but infinitely without ever having to land.
The bird can keep jumping infinitely through the air with no cooldown. Not intentional.

B1.5

Escape key
The game should bring up the pause menu and freeze the game in the background
The pause menu successfully pops up, and each button can be clicked on
The quit button doesn’t work in the editor, but when the game is exported as a build it will work fine
29/11/15
B2.0
The bird should be able to stand on platforms with a physics collider attached, and shouldn’t fall through out
Position the bird on top of a platform
The bird falls and lands on the ground, and it stops them falling any further
The bird is capable of standing on a platform

30/11/15
B1.4
Can the player make the bird perform an action depending on the key pressed? (Repeated test)
Space bar
The bird should jump and play the jump animation, if the player presses spacebar again before you land perform a double jump
The bird is able to jump, double jump and play the jumping animation, and they can only jump/ double jump once until they touch the ground again
As of 30/11/15 the infinite jumping it was fixed. Now the code for jumping and double jumping only works once and is reset once the bird hits the ground again. So they can’t just jump in the air forever (See screenshot in player input blog post for photo evidence.)
4/12/15
B3.0
Does the camera follow the bird around the level?
Move the bird off-screen
If the bird moves off-screen the camera should follow them (but still not move under the stage when the player falls, as there are boundaries below it)
The camera successfully follows the bird around the level, however it can follow them under the stage too breaking the immersion of the game
Fixed as of 6/12/15. The camera boundaries can be customised at any time in the camera’s settings
5/12/15
B4.0
Can the level restart if the bird falls down a hole?
Make bird fall off the stage
If the bird falls off a stage then the level should restart
When the bird falls down a hole the level restarts successfully
A huge invisible object with a simple collider is stretched under the whole level, so when the bird hits that restart the game
7/12/15
B3.0
Does the camera follow the bird around the level? (Repeated test)
Move the bird off-screen
If the bird moves off-screen the camera should follow them (but still not move under the stage when the player falls, as there are boundaries below it)
The camera successfully follows the bird around the level, and also stops following them when it gets to certain points, success!

12/12/15
B5.0
If the player collides with a dangerous object, does it cause them harm and show feedback/ affect the UI healthbar?
Collide with a dangerous object
If the player hits a spiky object, they will be knocked back, play the bird’s damage animation and take 1 point of damage while losing 1 point of health from their healthbar. After 5 points they should die and restart the level
If the bird hits the object from the side, they will successfully be knocked back, play the injured animation and take 1 point of damage. However if they jump on top of the dangerous object, they will die instantly unintentionally. Also the healthbar UI will not change and is bugged to a static image
The damage code is inside various game objects, from cacti, to spikes, fireballs and floating spikeballs
13/12/15
B5.0
If the player collides with a dangerous object, does it cause them harm and show feedback? (Repeated test)
Collide with a dangerous object
If the player hits a spiky object, they will be knocked back, play the bird’s damage animation and take 1 point of damage. After 2 points they should die and restart the level
If the bird hits the object from the side, they will successfully be knocked back, play the injured animation and take 1 point of damage. However if they jump on top of the dangerous object, they will die instantly.
Removed healthbar and reduced the bird’s health to 2 for balancing reasons, taking 5 hits made the game too easy. Still have a lingering issue with landing directly on spikes though
15/12/15
B5.0
If the player collides with a dangerous object, does it cause them harm and show feedback? (Repeated test)
Collide with a dangerous object
If the player hits a spiky object, they will be knocked back, play the bird’s damage animation and take 1 point of damage. After 2 points they should die and restart the level
If the bird hits the object both from the side and from above, they will successfully be knocked back, play the injured animation and take 1 point of damage.
Previously on the 12th and 13th the damage code was bugged, however the code was amended and now the player takes 1 point of damage from all angles (See screenshot in damage blog post for photo evidence.)
17/12/15
B6.0
Can the game switch to the next level when required?
Move the bird near a door (marked at the end of a level) and press the E key
The game should load the next scene and spawn the player into the new level when the bird collides with the door game object and presses E. It also draws instruction text onto the screen, and changes the text when the bird moves away again
The next level is successfully loaded after the player is both touching the door and pressing E, and the text is drawn onto the screen too
The door code is outdated and not recommended to use as of Unity 5.3 (it was implemented before the update), so it will need to be changed later-on, with another repeated test that I must also perform.

(I did another test on 07/01/16 late on, as I downgraded my Unity version back to 5.1)
19/12/15
B7.0
Testing to see if the collectable coins function correctly
Make the bird run into and collect a coin
The coin should destroy itself, play a sound and add 1 point to the score at the top of the screen
The coin successfully destroys itself, play a sound and add 1 point to the score at the top of the screen
Your score is also saved and carries over between levels in conjunction with the game’s doors. But if you die in a scene your score resets back to what it was at the start of that stage.
22/12/15
B8.1
Do the enemy dinosaurs have working AI?
Move the bird within a certain distance of a sleeping dinosaur
Wh en the bird gets close to the dinosaur, it should play the ‘waking up’ animation look either left or right towards the player. If the player leaves again the dinosaur goes back to sleep.
W hen the bird gets close to the dinosaur, it plays the ‘waking up’ animation look either left or right towards the player. If the player leaves again the dinosaur goes back to sleep.
Multiple dinosaurs originally spawned at the same position, but were quickly changed without the need of modifying code as I’d included a set position in-game in the dinosaur’s animation window

B8.2

Make the bird stay close to the dinosaur, within that set distance required for it to wake up
If the bird as visible to the dinosaur for a certain amount of time, it shoots a fireball towards the player’s position that damages them in the same way as spikes do upon contact
The dinosaur never instantiates a fireball, and doesn’t work as intended
The dinosaur plays the waking animation just fine, but never attempts to attack the player
26/12/15
B6.0
Can the game switch to the next level when required? (Repeated test)
Move the bird near a door (marked at the end of a level) and press the E key
The game should load the next scene and spawn the player into the new level when the bird collides with the door game object and presses E. It also draws instruction text onto the screen, and changes the text when the bird moves away again
The next level is successfully loaded after the player is both touching the door and pressing E, and the text is drawn onto the screen too
The code was successfully re-written from loading ‘load level’ to ‘scene manager’, it has all been tested again and works the same way as before, only loading times are faster now too!

(I did another test later on as I downgraded my Unity version to 5.1)
28/12/15
B8.2
Do the enemy dinosaurs have AI that is still broken? (Repeated test)
Make the bird stay close to the dinosaur, within that set distance required for it to wake up
If the bird as visible to the dinosaur for a certain amount of time, it shoots a fireball towards the player’s position that damages them in the same way as spikes do upon contact
The dinosaur still does not instantiate a fireball upon waking up
Modified the dinosaur’s code to no avail, also changed a lot of its animation properties and settings
29/12/15
B8.2
Do the enemy dinosaurs have working AI? (Repeated test)
Make the bird stay close to the dinosaur, within that set distance required for it to wake up
If the bird as visible to the dinosaur for a certain amount of time, it shoots a fireball towards the player’s position that damages them in the same way as spikes do upon contact
The dinosaur now successfully attacks the player. When you get nearby it will wait for a set amount of time and shoot a fireball at you, and if you’re hit it will deal 1 point of damage, knock you back and play the bird’s damage animation
After days of modifying code, the dinosaur’s AI finally works as intended. This needed to be one of the most tweaked scripts of my game to get it to function properly, with three different test logs with different code and properties included each time (See screenshot in AI blog post for photo evidence.)
31/12/15
B9.1
Does sound play in my game?
Load the game
When the game loads, play the looping background music
The background music plays correctly when the game begins
The music clip is attached to a black game object inside an audio source component, and is set to play at the start of the game and loop forever (See screenshot in sound blog post for photo evidence.)

B9.2

Press spacebar
When the bird jumps with space, play the jump sound. Also play the jump sound when the player double jumps.
The sound plays correctly when the bird jumps


B9.3

Make the bird collide with a coin
When the player collects a coin, play the corresponding sound
The correct sound plays when a coin is collided with

07/01/16
B10.0
Does the game have a 3-minute timer that counts down?
Load the game
The timer should count down from 180 seconds, and when it reaches 0 kill the bird and restart the game
The timer counts down as planned and resets the stage when it reaches 0
The time counts in milliseconds, but is only visible in seconds to the player as to not make the HUD too convoluted (See screenshot in score blog post for photo evidence.)
07/01/16
B6.0
Can the game switch to the next level when required? (Repeated test)
Move the bird near a door (marked at the end of a level) and press the E key
The game should load the next scene and spawn the player into the new level when the bird collides with the door game object and presses E. It also draws instruction text onto the screen, and changes the text when the bird moves away again
The next level is successfully loaded after the player is both touching the door and pressing E, and the text is drawn onto the screen too
My game’s Unity version was downgraded back to 5.1 since that’s what version of Unity the PCs at Uni have. So I rewrote the code to use ‘load level’ again.






Now for White Box Testing. Before I started making the game I created three UML diagrams (shown in the planning blog post) to show the code's structure and layout. The code itself has changed since then with those initial plans, but it still follows the same basic structure and layout since the game's code itself was based on those diagrams. This test-log below shows examples of me testing various different scripts and functions within my code, to see if they work as intended and what their output is.

White box test-log:

Date

Test No
Class

Function
Test purpose
Input

Expected output

Actual output

Additional comments

27/11/15
W1.1
Player
Void Update ()
Handles the keypresses of the player
Horizontal
Flip the bird left when left is pressed
The bird flips left


W1.2



Horizontal
Flip the bird right when right is pressed
The bird flips right


W1.3



Jump
Apply a force below the bird and move it up. Checks to see if you’re touching the ground before jumping is allowed again.
The bird jumps, and also can double jumps again. Checks to see if you’re touching the ground before jumping is allowed again. Also as of 31/12/15 the bird makes a jumping sound.
Can only jump when the bird touches the ground, and the grounded variable is set to true
28/11/15
W2.1
Player
Void FixedUpdate ()
Handles the keypresses of the player
Horizontal
Apply a force to the right of the bird and move it
The bird moves right at a set speed






Horizontal
Apply a force to the left of the bird and move it
The bird moves left at a set speed


W2.2



Release horizontal
Stop applying the force to the bird and it slows down due to friction
The bird gradually slows down and then stops

7/12/15
W3.0
CameraFollow
Void FixedUpdate ()
Code that makes the main camera track the player’s position and follows the game object whenever it moves
Transform.position. x, player.transform.
position.x
Whenever the player moves left or right, make the camera follow their position too
The camera  follows the player in a smooth motion
The camera has set boundaries that are assigned in the game object’s inspector view, it prevents it from moving out of bounds and stops the player from seeing outside of the level
12/12/15
W4.0
Player
Void Die ()
Function is called when the player dies
Col.gameobject.tag == “Bullet”
Restart the loaded scene and kill the bird
The level successfully restarts

13/12/15
W5.1
Player
Void OnTriggerEnter2D ()
Code is run depending on the tagged object that is collided with
Col.gameobject.tag == “Spike” at 2 health
Knockback the player, deal 1 damage and play the damage animation
The bird gets knocked back, receives 1 damage and plays the damage animation
Code that runs depending on the object the bird collides with

W5.2



Col.gameobject.tag == “Spike” (or “Bullet”)  at 1 health
Reference the ‘Die’ function. Restart the level and kill he bird
The level restarts as intended


W5.3



Col.gameobject.tag == “Pit”
Reference the ‘Die’ function. Restart the level and kill he bird regardless of your health
The level restarts as intended

19/12/15
W5.4



Col.gameobject.tag == “Coin”
Add 1 point to the score in the GameMaster script, destroy the coin object and play the coin collection sound
The coin gets collected as intended

19/12/15
W6.1
GameMaster
Void Start ()
If you’re in the first level of the game, set the value of the score to 0
SceneManager.
GetActiveScene
().buildIndex == 1
When you start the first level, the displayed score will be 0
The score is successfully 0 when the first level starts
Linked to the coin collection code above

W6.2

Void Update()
Display the text ‘Points:’, that changes whenever a coin is obtained
gm.points += 1; (in Player script)
The score goes up by 1 every time a coin is collided with
The score displays at the top-right of the screen, and increases by 1 for every coin

20/12/15
W7.1
Door
void OnTriggerStay2D (Collider2D col)
Test to see if the door object’s code works
(Input.GetKeyDown ("e"))
When the player collides with the door draw text on the screen, and when they press E inside the collision box, advance to the next scene, and save the current score
The next level loads after pressing E. Score carries over. The text is drawn on the screen when the bird collides with the door
There are four different doors and scripts for four levels of the game

W7.2
Door1
void OnTriggerStay2D (Collider2D col)
Test to see if the door object’s code works
(Input.GetKeyDown ("e"))
When the player collides with the door draw text on the screen, and when they press E inside the collision box, advance to the next scene, and save the current score
The next level loads after pressing E. Score carries over. The text is drawn on the screen when the bird collides with the door


W7.3
Door2
void OnTriggerStay2D (Collider2D col)
Test to see if the door object’s code works
(Input.GetKeyDown ("e"))
When the player collides with the door draw text on the screen, and when they press E inside the collision box, advance to the next scene, and save the current score
The next level loads after pressing E. Score carries over. The text is drawn on the screen when the bird collides with the door


W7.4
Door3
void OnTriggerStay2D (Collider2D col)
Test to see if the door object’s code works
(Input.GetKeyDown ("e"))
When the player collides with the door draw text on the screen, and when they press E inside the collision box, advance to the next scene, and save the current score
The next level loads after pressing E. Score carries over. The text is drawn on the screen when the bird collides with the door

22/12/15
W8.1
DinoTurret
Void Update ()
Used to see if the Dinosaur should turn left or right
target.transform. position.x > transform.position.x
If the bird’s x (horizontal) position is greater than the dino’s, make them face right to match the bird’s position



W8.2



target.transform. position.x < transform.position.x
If the bird’s x (horizontal) position is less than the dino’s, make them face right to match the bird’s position



W8.3

Void RangeCheck ()
Used to see if the Dino’s AI behaviour should  change depending on the player’s distance
if(distance < wakeRange)
If the bird’s position is smaller than the dino’s (they’re close by), wake them up
The dinosaur wakes up when the bird comes within a set range
When the dinosaur is set to awake, then it can start attacking the player

W8.4



if(distance > wakeRange)
If the bird’s position is greater than the dino’s (they’re further away), keep sleeping
The dinosaur goes to sleep when the bird moves a certain distance away


W8.5

Public Void Attack ()
Code that handles the dinosaur’s attacking. When a bullet should be instantiated and in what direction
if (!attackingRight)
If the dinosaur Is facing left towards the player, attack to the left (the ! means the opposite, so not facing right means it must be left). Spawns a fireball towards the player that damages them upon contact using the previous damage code
The dinosaur faces the player and shoots a fireball at them every 1.8 seconds. If you’re hit, the bird takes damage, knockback and plays the damage animation
The dinosaur stops firing if the player moves away again





if (attackingRight)
If the dinosaur Is facing right towards the player, attack to the right). Spawns a fireball towards the player that damages them upon contact using the previous damage code
The dinosaur faces the player and shoots a fireball at them every 1.8 seconds. If you’re hit, the bird takes damage, knockback and plays the damage animation

31/12/15
W9.1
PauseMenu
Void Start ()
Code that disables the pause menu on startup
PauseUI.SetActive (false);
Hides the menu when the game first loads
The pause menu does not appear when the game first starts
You don’t want the game to instantly pause when you start the game, or else it’ll block the screen!
01/01/15
W10.1

Void Update ()
Code that makes the core of the pause menu function
(Input.GetButton
Down ("Pause")
When the player presses Escape during gameplay, pause the game by bringing up the menu and stopping the game
The menu loads up as intended when you press Esc
A toggle-enabled pause menu using two if statements to switch between states

W10.2



(Input.GetButton
Down ("Pause")
When the player presses Escape while already paused, unpause the game and unfreeze the delta time
The menu closes correctly when Esc is clicked

02/01/16
W11.1

Public Void Continue()
Handles the function for the continue button
Continue button clicked
When the player presses continue during while paused, unpause the game and unfreeze the delta time
The game unpauses and continues as normal when this button is clicked
Each of the 4 pause menu buttons have their own separate functions

W11.2

Public Void Restart()
Handles the function for the restart button
Restart button clicked
Reloads the level that is currently loaded to restart the game
When restart is pressed on the current level restarts


W11.3

Public Void MainMenu()
Handles the function for the main menu button
Main menu button clicked
Uses LoadLevel to load the main menu’s scene
Takes you to the main menu scene when clicked as intended


W11.4

Public Void Quit()
Handles the function for the quit button
Quit button clicked
Simply closes the Unity application
Clicking the button in the built version of the game (not in-editor) exits the application

03/01/16
W12.1
MainMenuButtons
Void Start()
Handles the help box toggle when the game loads
infoOpen = false;
Hide the help section of the main menu when the game first loads
The main menu hides as intended upon the game’s bootup
We want to hide the help-box at first as the text box is rather large, and covers a portion of the screen where most players may only want to read it once and never need to view it again
04/01/16
W13.1

Public Void StartGame()
Handles the function for the start button
Start button clicked
Loads the scene for the first level in the game
When you click the button, it loads the first level
Like the pause menu, each button has their own function that reacts on click

W13.2

Public Void TestLevel()
Handles the function for the test level button
Test level button clicked
Similar to the start button, only loads the level that was used for testing the game’s mechanics instead
Loads the test level successfully on-click


W13.3

Public Void InfoPanel()
Handles the function for the how to play button
How to play button clicked
On button press at the start of the game, it should unhide the big text box that explains the controls to the player
When the button’s clicked the textbox is successfully toggled on
Two tests for this button, one to see if the help box appears, and one to see if it hides again

W13.4




On button press when the help box is already on the screen, it should hide the big text box that explains the controls to the player out of view
When the button is clicked for a second time, the hint box is hidden again


W13.5

Public Void Quit()
Handles the function for the quit button




07/01/16
W14.1
GameMaster
Void Update()
Decides when the timer should count down, and what happens when it reaches 0
if (timer > 0.1)
If the timer value is greater than 0.1, continue counting down from 180 seconds
The timer counts down for three minutes as intended when the game loads
Uses two if statements to make a choice, whether or not the timer is above or below a certain value and what to do accordingly

W14.2



if (timer < 0.1)
If the timer value is less than 0.1, kill the bird and restart the level
When the timer reaches 0 (from whatever value it started at), the level restarts successfully




No comments:

Post a Comment