Unit tests are small tests designed to exercise specific components of a program, such as individual functions. The goal is to test components in isolation, allowing for: more targeted and thorough testing, quicker detection of errors, and finer grained debugging. Further, ensuring the correctness of the low level building blocks helps to better ensure the correctness of the overall program. Unit tests can also easily detect low level errors that might be masked by other logic in the program.
Marcus did not become a master wizard by being lazy. Unfortunately, it seemed as though the apprentices these days did not appreciate the value of hard work. His newest apprentice, Shelly, was obsessed with moving onto complex spells.
"You have to master the fundamentals first." Marcus insisted.
"But, I already know the fundamentals." Shelly responded petulantly.
Marcus sighed. Kids these days were so difficult. In his day, an apprentice did not argue with his or her master. You listened and were respectful. Why was everyone suddenly so impatient? Marcus blamed the latest pop culture fad: marching bands. Sadly, there was only one way to reinforce the value of correct building blocks.
"Okay." Marcus responded. "Today we will do the spell of Transmogrified Mold, which transforms ordinary house mold into a candy. It is a complex spell that requires six potions and three hours. Are you able to handle that?"
"Yes!" agreed Shelly readily. She was visibly bouncing with excitement.
Marcus smiled as he handed her the directions. "Here you go then. There should be plenty of mold in the kitchen. I believe a certain apprentice has not cleaned there in weeks."
Ignoring the comment, Shelly ran off to the kitchen to begin the spell.
The key to the spell of Transmogrified Mold was correctly making each of the six potions. If any one of the potions is off by even a little, the product is a complete failure. Granted, the result will still look, taste, and smell like chocolate. However, it will cause three hours of intense nausea and powerful hiccups. Together, those turn out to be a most unpleasant combination.
While Shelly buzzed around the kitchen working, Marcus decided to take a nap. No need to remind Shelly to test each potion individually. By this point in her training, the value of testing should be ingrained. Of course, young apprentices always complained that testing their potions slowed them down too much. But, there was really only one way to learn the value of unit testing potions.
Three hours later, Marcus was woken by the sound of loud vomiting. "I believe she is done." he mumbled to himself as he made his way down to the kitchen.
There he found Shelly, with her head in a bucket.
"How did it go?" he asked.
"I don't know what went wrong." moaned Shelly between hiccups.
"Well, let me just see." offered Marcus. He wandered over to the counter and started testing the individual potions.
The first three were correct.
"Ah. Too much vinegar in the fourth potion. Common mistake. My guess is that you did not notice, because there is too much salt in the last potion. Yep. There it is. All very common."
"But, they all looked correct." Shelly protested between powerful hiccups. "And the end result seemed to work out."
"You will be fine in another two hours and fifty three minutes. Until then, I would recommend keeping a bucket close." Marcus advised.
He paused at the door on his way out. He did not look back as he spoke. "And in the future, I would encourage you to thoroughly test each individual component of a spell. You need to make sure the fundamentals are correct before building off of them. Otherwise, you can find unpleasant surprises."
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.