Week 25 · Unit 10: Be a game developer · 3 lessons
3
Test and improve
Computing 6: Unit 10, pp. 134–149
GoalTest a game against its criteria with a test plan, find a bug and improve the game using feedback.
New words
debug · to find and fix a bug in a programplaytest · trying a game as a player to find bugs and ideas for improvementfeedback · comments from players about what works and what does notevaluate · to check whether a program meets its criteria and could be better
Explanation
A finished game is not finished until it is tested. First write the criteria, which are the things the game must do. Then make a test plan with the action, the expected result and the actual result for each test. Test normal cases and the edges, such as a score of exactly 5 or a clock at 0. If an actual result is different from the expected result, there is a bug. Fix one bug at a time and then run all the tests again, because a fix can break something else. After that ask friends to playtest and listen to their feedback. Use the feedback to improve the game, and keep a copy of the old version in case you need it.
Test
Expected result
give a right answer
score goes up by 1
give a wrong answer
score stays the same
score reaches 5
level 2 and the night backdrop
20 seconds pass
the game stops and shows the score
Worked examples
Test
Expected
Actual
Result
right answer 12 for n = 6
score + 1
score + 1
pass
wrong answer 5 for n = 6
score stays
score + 1
FAIL
score reaches 5
night backdrop
night backdrop
pass
20 seconds pass
game stops
game stops
pass
This is the test plan with the results of a first run. Three tests pass and one fails. The failed test points to the bug.
The failed test says that wrong answers add to the score. In the script the change block is outside the if block. It must be moved inside the then part.
Feedback
Improvement
the first questions are too easy
start level 1 with numbers 1 to 5
I cannot tell how much time is left
show the time left on the stage
the game stops without warning
say ‘Time is up!’ before the final score
Feedback from players turns into improvements. A good improvement answers one clear problem.
Class activity
Playtest swap (no computer): make a small paper game with a friend, for example a number game with cards and a scoring rule. Write the criteria on a card. Swap games with another pair. The new pair plays and fills in a test table with at least three tests: what they did, what they expected, what happened. Then they tell you one thing that was good and one thing to improve. Make one change, play again and test again. If you have a computer or tablet, test your own Scratch game in the same way.
Practice
1
The score is always 0 or 1, even after many right answers. Find the bug and explain how to fix it.
The block set score to 0 is inside the loop, so the score is reset to 0 before every question. Move it above the loop so that it runs only once at the start.
2
A rule says that level 2 starts at a score of 5 or more. Write three boundary tests with the expected results.