- Go download MXUnit
- If you're using Eclipse, install the Eclipse plugin
- Somewhere in your codebase, create a directory named "tests" (or whatever)
- Pick a fairly easy existing component that you've already written. Let's say it's named "Bob". Now, go to your tests directory and create a new file called "BobTest.cfc".
- Inside that file, add a cfcomponent tag and have it extend mxunit.framework.TestCase
- Then, pick a function in Bob to run. Maybe it's "init". Think to yourself, "What's one thing this function should do?" Then, back in your test, write a new test function, something like ....
- Run the test to confirm everything's "hooked up" correctly. This test should pass.
- Now, try to write a simple test for Bob.init() by creating an instance of Bob and invoking its init() function. Write an assertion or two on the result of that call to init().
Thanks! To all who attended, thanks for spending so much time with me. And thanks to Rick and Nick for setting it all up. Here's some follow-up: Remember my onMissingMethod / UserBean problem? Turns out, the reason the test was failing was that I needed to call user.setid(id=5), not user.setid(5). Umm...... that ain't cool. So I wrote some notes into bean.cfc and userbean.cfc for refactoring. Give those refactorings a shot! Follow-up, or, What to do next