Yep, programmers love writing tests! It's especially fun in a high-level language, where you can whip up abstractions with break-neck speed. I've found macros especially useful for testing. For one thing, macros are great for abstracting over before/after patterns (so much better than the setUp/tearDown idiom in JUnit). Another thing they're great at is data languages, which can be useful for describing an expected result or interaction sequence.
Some of the tools available for PLT Scheme that make testing such a joy -- aside from higher order functions and macros, I mean -- include SchemeUnit and PLaneT. I don't think I can underestimate the importance of PLaneT. Without a release mechanism, code reuse is nothing but a pleasant fantasy. And now that SchemeUnit is in PLaneT, I can actually release my tests with my code, so anyone can try them out.
An up-and-coming beauty is MzTake, a scriptable debugger based on event monitoring. Tonight Sam and I debugged a concurrent procedure, and I automated our tests with asynchronous channels. This is very cool, and a big improvement over the brittle, timing-based test scripts I used to write in Perl. But I still had to instrument my code by hand (thereby polluting the primary functionality of the code -- an AOP no-no). I'll try some MzTake scripting soon to see if I can do any better.
Thursday, February 17, 2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment