Have students write test cases before they write code to get them thinking about what could possibly go wrong and how to avoid it.