Unit Testing in Education

In my readings of Extreme Programming, one thing I’m struggling to pick up on is Unit Testing. Mostly, it’s the pain of writing tests for each thing I can imagine goes wrong. Partly it’s an imaginary horror: I think about the full extent of testing all at once. I think about exhaustively testing my program’s behavior. But in reality, writing the tests is not that bad. You don’t sit down and write a hundred unit tests for every little thing you can think of. Rather, you test (and program) incrementally. So, my overactive paranoia about what I have to test doesn’t represent the reality of testing. Instead of imagining everything at one, I’ll have to train myself to focus on the small, achievable, easily testable things.

Once I get over that, and actually start to write my tests, I’ve noticed some other effects. Writing the tests before the code, actually gives you a good idea of how I’ll want to interact with the code. The very act of hypothetically using it gives me a more concrete picture of what I want to accomplish. The burden of writing the test helps to keep the complexity down. You end up with a better mental model, cleaner architecture, and fewer dependencies.

Ok. Great. So unit testing my code has nice benefits. But can it be applied elsewhere? Say, in education?

Well certainly you could teach unit testing philosophy. You could drill into your students the virtues of unit testing their code. But that’s not what I mean by applying unit testing to education. I mean, that we should look at the education process itself, and see where unit testing fits.

Most classes consist of some mix of the following:

  • Lecture and Discussion.
  • Exams. Quizzes, Midterms, and Final.
  • Assignments. These can be Projects (individual and group), Research Papers, Homework drills, etc. Work that the students are responsible for doing, and which they hand in for a grade.

Looking at these components, we should ask ourselves: How effective is each piece in contributing to the total outcome? How does each add to a students memory and experience? How well does each help the student learn? When we follow these questions an interesting picture begins to emerge.

The purpose of lecture is typically used to demonstrate some of the concepts through pretty pictures, compelling narrative, and highlighting of important things to remember. Discussion sections are typically used to get the students somewhat involved with the material. That is, we expect active participation in discussion vs passive participation in lecture. Assignments are typically used to give the students practice with the material. They are contrived to highlight certain aspects of the field, or certain skill sets that have been found useful in actual research. They are a way to artificially build experience.

Exams and quizzes stand apart in that they don’t necessarily contribute to student learning. Rather, they are used as a metric for assessing how much knowledge the student has absorbed, or how well they are able to assemble that knowledge for solving a problem. These devices are pedagogical unit tests. But, unlike unit tests I write for my code, they are exercised last, not first. They aren’t exercised often, and they don’t really follow iterative development.

So, now that we’ve identified a component of our educational system that’s analogous to the extreme programming methodology, how do we improve our classroom techniques to actually use the same methodology we want to teach?

Maybe the tests should come first. Instead of having final exams as an exit criteria, we should have entrance exams as a placement/enrollment criteria. I’m not quite sure how well this would work, but it should improve the relationship between teacher and student. No longer are the teacher and student in adversarial positions about the grading outcome.

Quizzes are a great way to measure incremental progress, and many instructors already use them as an appropriate feedback mechanism about the material. In fact, a first-day quiz about ‘what do you expect to get from this course’ is often a great way for an instructor to customize the material to student learning objectives. Just as programmers use unit tests to pinpoint software errors, we can use quizzes to pinpoint conceptual errors where they occur.

The XP methodology seems to suggest that a comprehensive test is not the way to go. Rather, it’s better to have a greater number of smaller quizzes which test specific items. It also suggest running tests repeatedly. For humans, too much repetition can become monotonous, but just enough definitely improves retention. We also want to make sure that the most recent material learned doesn’t supplant material covered at the beginning of the course.

Finally, and most radically, XP suggests writing your own tests. I think it would be a great world if students became responsible for their own learning outcome. And what better way to motivate them, than by feeding back their own ‘what if’s on the tests? Coming up with good questions is actually very difficult, and provides an altogether new way of viewing the material. It forces a re-conceptualization of what was learned, providing yet another avenue of engagement. I think it will also viscerally demonstrate that the students aren’t helpless sheep waiting to be watered with a font of knowledge from the professor. IF we can find a way to incorporate this radical step, I think it would help to form a cycle of learning (ask questions, analyze answers, repeat!) and give our students practice with the self-reliance they will need in the real world.