Prerequisites
Copy cobertura.jar (1.9.1), asm-3.0.jar, asm-tree-3.0.jar, jakarta-oro-2.0.8.jar, log4j-1.2.15.jar totally 5 jars to a folder (in this case it is: "/home/lichao/apps/coberturaLib").
If using cobertura-2.0.3, copy cobertura.jar and all jars in folder "lib" to "coberturaLib".
The current working directory is project home folder, under which there are 3 folders: cmd, conf, lib.
Instrument
Now we need instrument class files under "class" folder to "instru" folder:
java -cp "/home/lichao/apps/coberturaLib/*" net.sourceforge.cobertura.instrument.Main --destination instru class
Note the double quotes of "/home.../coberturaLib/*" is necessary.
If you use cobertura-2.0.3, add project dependencies ($PROJ_HOME/lib), too:
java -cp "/home/lichao/apps/coberturaLib/*:../lib/*" net.sourceforge.cobertura.instrument.Main --destination CalcServer --datafile CalcServer/cobertura.ser CalcServer.jar
Synopsis:
java -cp <Cobertura_lib> net.sourceforge.cobertura.instrument.Main --destination <dest_folder> --datafile <datafile_path> <target>
If
Start Server
This step equals to "unit test" in junit-cobertura scenario. The start.sh is:
1 2 3 4 |
|
Note: The instrumented jar must be add before uninstrumented jar in classpath.
Synopsis:
java -cp <cobertura.jar_path>:<other_dependencies> -Dnet.sourceforge.cobertura.datafile=<datafile_path> Server.Main.Class.Name
Merge Datafile
java -cp "coberturaLib-2.0.3/*" net.sourceforge.cobertura.merge.Main --datafile GcpCollector/cmd/cobertura.ser GcpServerCore/cmd/cobertura.ser cobertura.ser
Get Report
java -cp "/home/lichao/apps/coberturaLib/*" net.sourceforge.cobertura.reporting.Main --datafile cobertura.ser --destination ../report ../../src
The report data will not be written to report files until the server process is down.
Synopsis:
java -cp <cobertura_lib> net.sourceforge.cobertura.reporting.Main --datafile <datafile_path> --destination <report_path> <source_folder>