Here is an interesting summary of the problem encountered by the Spirit probe on Mars. Important test lessons:
“test real-world conditions”
“run long-haul stress tests”
“SYSTEM BEHAVIOR: Spirit began acting up last week, when it stopped sending data and began rebooting its computer, resetting it roughly 130 times. At one point, the rover thought it was 2053.
BUG DESCRIPTION: Engineers found that the rover's 256 megabyte flash memory had retained hundreds of files containing flight data and was still juggling them along with the daily flood of new data from its activities in Mars' Gusev Crater.
WORKAROUND: By commanding Spirit each morning into a mode that avoids using the flash memory, engineers plan to begin deleting hundreds of unneeded files to make the memory more manageable for the rover's RAM.
WHY WASN'T THIS CAUGHT IN TEST?: The bug had not been detected in operational tests of the rover on Earth because the longest tests lasted only eight or nine days.”