Thursday, December 05, 2013

How Do You Know It Works?

I have been teaching Visual Basic programming to my freshmen this week. It’s part of a course we call Explorations in Computer Science and its new this year. The students are working on a simple program to do temperature conversions – Fahrenheit to Celsius and back again. It’s deliberate fairly simple because the idea is to get them used to the IDE, using assignment statements and simple formulas, and generally get their feet wet. I go around the room helping out here and there, repeating some information again, and of course letting the students who off their working programs. And that is when it gets interesting.software-testing

A student will run the program, type a number into a box, click on the button and a new number will display. My question then is “is that the right answer?” Fairly often the reply is along the lines of “I think so” or even “I don’t know.” I’m sure you are thinking “didn’t you talk to them about test data?” to which I reply “you betcha!” In fact I showed them (several times) some examples of good data – input values for which I (and they) know the correct output.

So why don’t students use that data? Oh how I wish I knew. Somehow beginners like to assume that once the program compiles, runs and displays an answer in the right place that all is good. Often it is not. In fact I accidently posted an incorrect formula which some students copied so answers were decidedly wrong. That showed up the first time a student entered good test data. As soon as the first student showed it to me I realized what I did wrong (cut and paste error). Students who didn’t test well would never have known though.

So obviously this is something I will continue to talk about throughout the course. I may share a story that Eugene Wallingford posted in his blog - AGILE MOMENTS, "WHY WE TEST" EDITION – about someone who surely wished they’d tested more.

Testing is a critical piece of any scientific or engineering endeavor. We need to teach students how to do it correctly from the start.

No comments: