Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Measuring code coverage with Cobertura on the serverside

 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(moved over from another thread
Originally posted by Rajkumar Chandrasekaran:
I have a situation here where i must find out the code coverage when my application is running. In more detailed terms, i compile the classes and instrument them and if i build a war or a ear file with the instrumented classes and deploy it on the server like tomcat or jboss and i hit the url the classes work fine, but where will the .ser (trying to use jcoverage). files will be created so that i can generate reports.

The default is to write the .ser file to "cobertura.ser" in the working directory. What that means for your Tomcat or JBoss installation, I don't know.

You can override the default at instrumentation time by giving the <cobertura-instrument/> task the "datafile" attribute, pointing to where you want the .ser file to be written.
 
Rajkumar Chandrasekaran
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I changed the build file to something like this <cobertura-instrument todir="${instrumented.dir}" datafile="c:\cobertura.ser">
and ran the sample script which came with the download. I am getting a error as follows
[cobertura-instrument] Cobertura: Error reading file c:\cobertura.ser: null
[cobertura-instrument] Instrumenting 1 file to D:\cobertura-1.8\examples\basic\i

please let me know if i am missing something here.

Thanks for the help

With Regards
Rajkumar
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you could try "C:/cobertura.ser" instead of "C:\cobertura.ser". If that doesn't help, you might want to email to the cobertura-devel mailing list as well.

Also, are you running Cobertura under the D: drive? Have you tried "D:/cobertura.ser" instead of "C:/cobertura.ser"?
 
Rajkumar Chandrasekaran
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the information, Finally got it to work,

Using corbertura -1.8 and tomcat the files got placed from where the server's executable was present. Was able to generate the .ser file and the reports as well.

Once again thanks for the information

Rajkumar
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic