InfoQ

News

Heckle Your Way to Better Tests

Posted by Obie Fernandez on Dec 20, 2006 08:45 AM

Community
Ruby
Topics
Unit Testing,
Programming
Tags
RCov,
Code Coverage,
TDD

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."

No comments

Reply

Exclusive Content

Measuring Agile in the Enterprise: 5 Success Factors for Large-Scale Agile Adoption

Michael Mah analyzes the development process in 5 companies: 2 Agile (one of them BMC) and 3 classic. He presents the factors which contributed to the success of BMC's Agile adoption.

Tom Preston-Werner on Powerset, GitHub, Ruby and Erlang

In this interview filmed at RubyFringe 2008, Tom Preston-Werner talks about how both Powerset and GitHub use Ruby and Erlang, as well as tools like Fuzed, god, and more.

David Laribee on Alt.NET and its Mission

David Laribee discusses the purpose of ALT.NET, its mission and future.

Discover RailsKits and Stop Writing Redundant Code

Ruby on Rails has become a popular Ruby framework for creating web applications in recent years. An aspect of creating a web application is the need to repeatedly create the same base functionality.

A Formal Performance Tuning Methodology: Wait-Based Tuning

Steven Haines talks about tackling web application performance tuning by proposing a method called wait-based tuning.

Shaw and Fowler About Forging a New Alliance

Shaw and Fowler talk about the need for a new relationship between the business department and the IT department. Studies have shown that projects mostly fail due to miscommunication between the two.

How to GET a Cup of Coffee

In this article, Jim Webber, Savas Parastatidis and Ian Robinson show how to drive an application's flow through the use of hypermedia in a RESTful application.

Archaeopteryx: A Ruby MIDI Generator

Eccentric artist turned overnight anti-celebrity, Giles Bowkett captures the heart and soul of RubyFringe as he demonstrates his revolutionary Archaeopteryx MIDI drum pattern generator.