Workshop
7.1 Activity: Applying testing heuristics
Consider the following code fragment:
if (heat < 0 || heat > 100)
System.out.println("Temperature is out of range.");
else if (heat < 33)
processLowHeat(heat);
else if (heat < 66)
processMediumHeat(heat);
else
processHighHeat(heat); Assume that the variable heat has been declared as an integer, and that the methods processLowHeat, processMediumHeat, and processHighHeat are defined elsewhere in the program.
Your friend tests this code with the following inputs for the variable heat: -1, 32, 33, 65, 66
Explain, using what you have learned about test heuristics in this unit:
- what is good about using this range of test inputs?
- how could the choice of test inputs be improved?
Answer
1. The test inputs -1, 32, 33, 65, 66 are well-chosen because they target the boundary values of each conditional branch. This helps ensure that the logic separating the temperature ranges is correctly implemented. For example:
-1 tests an invalid input below the minimum accepted range.
32 and 33 test the boundary between low and medium heat.
65 and 66 test the boundary between medium and high heat.
Using boundary values is an effective heuristic because errors often occur at the edges of input ranges. These inputs also provide path coverage, as they test each major logical branch of the program.
2. The current test set can be improved by adding:
Valid typical values within each category, such as 15 (low), 50 (medium), and 85 (high), to ensure typical cases work as expected.
More extreme values, like 0 and 100, to test the upper and lower boundaries more thoroughly.
Another invalid value, such as 101, to test inputs above the valid range.
Additionally, including duplicate or edge-equal values helps verify inclusive/exclusive conditions are handled correctly. These additions would support equivalence class partitioning and further strengthen the test coverage.7.2 Activity: Software disasters
Failing to test software thoroughly can have enormous real-world consequences! Below is a list of some famous disasters (or near disasters) that have occurred over the last century, caused by software bugs.
- NASA Mariner 1 (1962)
- Undetected hole in ozone layer (1985)
- Therac-25 radiation therapy machine (1985-1987)
- Morris Worm (1988)
- AT&T long-distance network crash (1990)
- Ariane 5 (1997)
- NASA Mars Climate Orbiter (1998)
- Millennium (Y2K) bug (2000)
- Air Traffic Control System in LA Airport (2004)
- Knight Capital Group stock trading disruption (2012)
- Heartbleed security bug (discovered 2014)
- Boeing 787 Dreamliner power failure bug (2015)
In your groups, research one of these software disasters and discuss these questions:
- What was the software error?
- How was the error discovered?
- What was the impact of the software error?
- Who was to blame for this error?
- How do you think it could have been avoided?
Use the appropriately named text file opposite to note down your answers to these questions.