BT

New Early adopter or innovator? InfoQ has been working on some new features for you. Learn more

Heckle Your Way to Better Tests

| by Obie Fernandez Follow 0 Followers on Dec 20, 2006. Estimated reading time: 1 minute |

Like Jester, the Java program that inspired it, Heckle mutates your Ruby code, attempting to make your unit tests fail. The premise is simple: If your unit test doesn't choke on Heckle's mutated code, then you need to improve coverage. Especially in cases where the team writing the code is practicing Test-Driven Development, Heckle does a really good job exposing unused code.

According to lead author Kevin Clark, "Heckle works by using the ParseTree and RubyToRuby libraries to grab the abstract syntax tree of methods, modify them, and evaluate the redefined method before running your tests."

Heckle shouldn't replace a line-based code-coverage tool such as RCov, but makes a good complement, especially in the Ruby world. Ruby code relies heavily on single-line branches — whenever you use a ternary operator, or suffix a statement with an if or unless, you're creating a logical branch that line-based tools like RCov won't properly detect. (The examples given in introductory articles by both Kevin Clark and Aslak Hellesoy illustrate the concept vividly.)

I asked Aslak to describe how Heckle fits into good test-driven development, and he said, "RSpec/Test::Unit is your safety belt. RCov is your airbag. Heckle is your helmet, neck brace and full fireproof suit."

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