views:

70

answers:

2

I am not sure if this is possible but I would like some way to get code coverage information for tests that are written in Quick Test for our GWT based web app.

It does not seem like there is any solution because the Quick Test Pro tests are testing against the GWT compiled app and not the original java code in which the app was written. I suppose I could get coverage data on the javascript that the GWT compiler creates, but there would be no way for me (that I know of) to map this information back to the original java code.

Is there some way to do this?

+1  A: 

No because you don't want to test GWT (or the GWT compiler): You want to test your own code. So you should get a good coverage with normal unit tests and only test what you can't test this way with Quick Test.

Aaron Digulla
A: 

If I understand the problem, you code in Java, GWT translates that to JavaScript, and you want coverage information on the Java program obtained from running the GWT-compiler version?

If so, there's a way to do it. The SD Java Test Coverage tool instruments Java source code to collect its coverage data.

If you ran the SD test coverage tool, what you get is instrumented Java code. If you compile and run that with GWT, the instrumentation will still collect the data as if the program were running as Java.

The instrumentation builds a trivial array of booleans at runtime. Normally that is dumped by the instrumented Java program to a file as it "exits" (for a variety of definitions of "exit"). The dump logic is pretty trivial (loop over the array and write the values) and customizable. Writing the equivalent for the Javascript code should be pretty easy.

With the exported instrumentation data, the SD Java Test Coverage tool will display your test coverage, on your original source code, as though you had executed the Java code itself. And it will be accurate.

Ira Baxter