开发者

Java : Which Code Coverage tool to use? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 9 years ago.

Improve this question

Here is what I want to do:

1) A running application has been instrumented. The byte code is clean - means that the tracing info should be added on the byte code level.

2) The running application might run for days or weeks. I want to have a trace file once per day.

3) If the tracing period is over I want to merge all trace files together and produce one HTML report for the developers.

Here is what I have investigated so far:

  • Emma seems to do a good job when it comes to issue 1) Instrumentation on the fly is very simple.

  • Cobertura says the are able to do byte code instrumentation but I havent found an example.

  • Neither Cobertura nor Emma talk about periodical trace file dumping.

  • Im not sure about clover. Maybe someb开发者_JAVA百科ody has had a look at it before.

Has somebody done this before and can help me with these Issues ?

Thanks, detlef


Cobertura will instrument your code fine. It will dump out .ser files that can be merged together.

The only part I have not tried is taking a snapshot every day. My two ideas are to try to either

a) What happens if you copy the .ser file off, and delete the old .ser file. Will it crash, or will it create a new .ser file? If it creates a new file, this would work.

b) Would it be possible to shutdown your app for 1 minute per day, to copy and delete the .ser file?

In either case, once you have a bunch of .ser files, it is real easy to merge them toegether and create a html report.


Clover is also nice.


Our SD Java Test Coverage Tool allows you at execution time to dump a test coverage snapshot at any time you like by calling a special method.

If you have a long running application and want a daily snapshot, you could add an extra thread that waited 24 hours, dump the snapshot, go back to sleep. Each snapshots gets its own date-stamped file. You can merge as many of these together as you like, and produce an XML coverage report (and then an HTML report in the format you like).


Disclaimer: I'm a Clover developer at Atlassian.

Regarding your requirements and Clover capabilities:

The running application might run for days or weeks.

If you want to collect only global coverage data, then it should be fine.

If you'd like to collect per-test coverage as well, then I guess that running tests for several weeks would produce a lot of data and it could heavily hit performance. But I believe you're not talking about such case here.

I want to have a trace file once per day

Clover allows to set data dump at specified intervals (for example a <clover-setup flushpolicy="interval" flushinterval="86400000">). See clover-setup for details.

It's worth to mention that Clover does not reset counters after flushing coverage data to disk. So actually there is no need to write one trace file per day (you can do it if you want of course), it's enough when Clover will write all data at the end.

I want to merge all trace files together and produce one HTML report for the developers

No problem do get this in Clover. This is actually a default behaviour to find all coverage recording files related with a given database during report generation.

It's also possible to generate multiple reports with links between them if you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜