Jester is a java test tool that finds code that is not covered by tests. It does this via bytecode mutation to modify code paths of the class under test. First it runs your tests and they should all pass (ass usual). Then it will modify conditionals for branching, change literals, and generally wreck havok, making one change at a time. By rerunning the tests per change, if they don't fail, then you've missed a test case. All in all this is pretty damn cool.
It turns out that getting a simple prototype up and running with 'if' node flipping takes about 100 lines of code. The meat of it is:
def process_defn(exp)
self.method = exp.shift
result = [:defn, method]
result << process(exp.shift) until exp.empty?
heckle(result) if should_heckle?
return result
end
def process_if(exp)
cond = process(exp.shift)
t = process(exp.shift)
f = process(exp.shift)
if should_heckle? then
[:if, cond, f, t]
else
[:if, cond, t, f]
end
end
I've named it heckle and released it on rubyforge and Kevin Clark went insane last night and poured through it, ruby2ruby, and ParseTree to dig deeper. I haven't seen him this morning yet so I don't know if he's succeeded extending it yet. We'll see. There will be a more official release soon.

That is seriously cool. Actually, Jester doesn't modify the byte code. It modifies the source code and recompiles it - which is why it's so slow.
Seriously cool, yeah.
This is one of the testing tools/tactics I've wanted to see for Ruby for a long time. Ruby testing is fast becoming a smorgasbord of... choice.
Very cool. I will have to try using this to get around rcov's lack of branch coverage.
BTW, it's "wreak havoc", not "wreck havok".
Very cool. I will have to try using this to get around rcov's lack of branch coverage.
BTW, it's "wreak havoc", not "wreck havok".