Becoming addicted to testing
If you're a follower of the faith of Extreme Programming, you probably already know this. If you're aspiring to convert to XP (extreme abbreviation for Extreme Programming) and want want to just be an all round better programmer, you need to build your tests. For me, it was hard getting used to this new methodology. I was just so used to self testing that after a while it became second nature. How did I overcome this nasty habit? With the oh so awesome ZenTest gem which canbe grabbed with the usual
gem install zentest
This gem contains some great libraries, of which you can read more about here. But the reason I wrote this post today is autotest. Once you have the zentest installed, and if you're cool enough to be developing in a *nix environment, all you need to do is cd into the root of your rails app and type in
autotest -rails
and you're off and running. If you developing in Windows, you'll get an error if you just try that right off the bat. The error will mention something about not knowing the HOME value so what we need to do is set it. Still in your railsapp root directory, type in
set HOME=C:\path\to\your\rails\app
gem install zentest
This gem contains some great libraries, of which you can read more about here. But the reason I wrote this post today is autotest. Once you have the zentest installed, and if you're cool enough to be developing in a *nix environment, all you need to do is cd into the root of your rails app and type in
autotest -rails
and you're off and running. If you developing in Windows, you'll get an error if you just try that right off the bat. The error will mention something about not knowing the HOME value so what we need to do is set it. Still in your railsapp root directory, type in
set HOME=C:\path\to\your\rails\app
After you've set Home, go ahead and fire up autotest with the autotest -rails command and your console/DOS window will spring to life. It also wouldn't hurt to run this in the Test environment so you can also prepare your test db (you have one in your database.yml right?) with a little:
rake db:test:prepare
Now you have no reason NOT to be testing, especially with it being this easy. Enjoy :)
0 Comments:
Post a Comment
<< Home