autotest -rails
Posted by topfunky
about one hour
ago
“You should spend at least half of your time in the
‘test’ directory.” — Jeremy Voorhis
“Quit looking at your web browser!” — Eric
Hodel
Web development without a browser?
My development process has recently been supercharged by
autotest, a part of the ZenTest package
that you can download from RubyForge or install
as a gem:
sudo gem install ZenTest
See a Movie of
autotest in action
Autotest runs continuously and watches to see what files you
have edited. Any time you save a file, it will run the
corresponding test within a few seconds. If a test fails, you can
see the result immediately. If it passes, you can write another
test, then the code necessary to make it pass, ad nauseam.
# Run this inside your Rails app's directory
topfunky$ autotest -rails
The revolutionary part of this is that it speeds development by
helping you develop without needing to open your web browser! I
find myself thinking more about the functional issues that need to
be solved rather than the placement of an image or the color of a
link.
And since it’s running continuously, you don’t have to wait for
your tests to run…they are running almost all the time. When they
do run, they often take less time since autotest intelligently
diffs the change and runs the test for a single method, when
possible.
It makes it hard NOT to do test-driven
development. You see the screen sitting there like a hungry fire
waiting for another test. Like a fire, it also has an infinite
hunger, so you will never beat it.
But the point is…by writing tests you can
-
Ensure that changes to your app won’t break
other functionality
-
Keep yourself on track by focusing your mind
on problems, solutions, and the most functional design
-
Speed your development by breaking out of the
write-refresh-wait-wait-wait-debug cycle