#1442 test coverage tool

timclark Tue 8 Mar 2011

How would I go about measuring the test coverage of Fantom code. In Java I typically use Cobertura to instrument the byte code, in .NET I try and use several tools that are supposed to give me coverage of NUnit tests and then give up and start crying, in Clojure I have a partially written crazy macro that wraps my functions in a piece of recording logic and then rebinds them.

I don't want to go the .NET route or the Clojure route - but their seem to be lots of interesting classes in the compiler pod, would this be the best route for me to investigate. If I can get hold of an anstract syntax tree I guess I could slap some statistics collection around all the function calls and conditionals in a pod and have some basic test coverage.

Am I missing something here, is this a good path to pursue or is their something in the Fantom internals that will prevent me from doing this?

Tim

brian Tue 8 Mar 2011

Well all Fantom just gets turned into Java bytecode, so tools designed to work with bytecode should theoretically work. So if Cobertura is something you are familiar with, might be interesting to try that.

As a first step, what I would suggest is:

  1. use jardist to get all your Fantom code into big jar
  2. use Cobertura as you would on any Java project

timclark Tue 8 Mar 2011

That would work but the output is very difficult to actually work with! I have tried this for Clojure and Scala and the output is very frustrating to interpret.

brian Tue 8 Mar 2011

I am not sure how Clojure and Scala map things to bytecode, but I would expect Fantom should be somewhat easy to interpret.

All your classes and mixins will map to normal Java types. Probably the ugly thing will be that your closures will get mapped to a funny named class - but it will be named by the enclosing class/method.

But the "fix-up" to pretty type/method class names is pretty simple, in fact we do it in Err.java as part of the stack traces.

Login or Signup to reply.