BT

Autotest - a hidden tool gem

| by Werner Schuster Follow 7 Followers on Dec 12, 2007. Estimated reading time: 1 minute |
One of the secrets of the Ruby community is why many developers prefer  text editors over IDEs. One reason is the group of tools - written in Ruby - that help to automate a lot of the tedium of coding. Some of these tools were recently featured in a poll on Pat Eyler's blog

One of these tools is Autotest, part of the Zentest package. The installation is simple:
gem install zentest 
While Zentest helps you write unit tests and synchronize your code with them, Autotest does exactly one thing: once started, it will re-run the tests whenever a file is saved. It's clever about it and only runs the tests that are deal with code in the saved files.

Eric Hodel, the creator of Autotest, explains his mode of work that led him to write Autotest:
Before I wrote autotest I was making fine-grained saves that were syntactically correct. I wrote autotest to automate the running of tests so I wouldn't have to choose which tests to run. My changes were so small that I spent an annoying fraction of my time editing my command line.
This also mentions another benefit of running the tests: the code gets loaded and checked at every save. Compare this to modern Java IDEs, that run a big set of static analyzers such as syntax and semantic checkers over code, either incrementally or when a save happens. A similar level of automated checking is achieved with Autotest, while still leaving developers in their preferred editor.

A plugin interface also allows to extend Autotest. This is as simple as creating a ".autotest" file in the project root. In this, either require existing plugins, or write some custom handlers for various hooks:
Autotest.add_hook :red { |autotest|   p "Failures!" } 
The first parameter is the name of the hook this hooks into - in this case a test failure. This code will simply print out "Failures!" if the tests didn't pass. This also allows to invoke other tools, depending on the outcome of the tests or simply at every save. Plugins for integration with Emacs or acoustic feedback are available.

Have you heard of Autotest before? Are you considering to use it?

Rate this Article

Adoption Stage
Style

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread
Community comments

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT