Skip to content

Testing the program

Once you have completed the code for this program you need to test that the features are all working. As this uses random numbers you cannot generate standard test data in order to check the execution. Instead, you should perform a number of executions and test the different paths through the program. The main condition you want to check are:

  • Test failing to get the number in seven guesses.
  • Test getting the number correct within seven guesses.
  • Check the output messages when your guess is less than the number (you can enter a guess below 0).
  • Check the output message when your guess is larger than the number (you can enter a guess larger than 100).
  • Ensure that the random sequence is different each time, if it’s not make sure you have seeded the random number generator.

Testing is a really important part of all software projects. It is easy to have small issues that go unnoticed. Remember that testing aims to find issues, so try different things to see how they go. You want to break it if you can.