White Box

Line: Method Line
Medium Difficulty Testing Learning Outcome Five Exercise
Type: Exercise
You should have completed:

Monthly Calendar

Test Plan

This topic leads to:

Record Sales

Tic Tac Toe

Summary

All of us make mistakes, so it is important to test any program or code you write to be as sure as you can that it is free from errors. Given some code, you will design a set of tests to check that the program is functioning properly. This is 'White Box' testing where you do have access to the code, and can therefore craft tests that make sure that every line of code is executed.

Task

  1. Download the example file here and copy and paste the code into a console application.
  2. Examine the code to see what it does and the paths of execution within it.
  3. Write a test plan for all the tests you must carry out on this program to be sure each line of code is executed at least once. Hint: You may need to look up "Astronomical Unit".
  4. Carry out that test plan. Did you find any errors?