File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Measuring code coverage with Cobertura on the serverside Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "Measuring code coverage with Cobertura on the serverside" Watch "Measuring code coverage with Cobertura on the serverside" New topic
Author

Measuring code coverage with Cobertura on the serverside

Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
(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.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Rajkumar Chandrasekaran
Greenhorn

Joined: Nov 23, 2004
Posts: 11
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

Joined: Jan 23, 2002
Posts: 11962
    
    5
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

Joined: Nov 23, 2004
Posts: 11
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Measuring code coverage with Cobertura on the serverside