From: *** F. S. Kumar*** <nsa...@gm...> - 2012-07-29 21:27:21
|
John: I follow below steps to create my code coverage report. In the reports, i see over all* 4%* coverage report and sometimes get *12%* coverage. This is not very promising to me. I think i may miss some process. Please take a look and help me. *Steps in my code coverage.* 1) After i instrument my jars, i see original cobertura.ser file getting generated. 2) I copied the cobertura.ser file to my working directory *C:\WorkingDir*. 3) From this working directory, i launch my client application (with instrumented EAR already deployed, up and running on AIX server ) using a batch file that brings my application running. 4) Then I start my automation testing using QTP. 5) As soon as my automation finish testing, I close my client application and i see cobertura.ser file in my working directory * C:\WorkingDir* is getting updated with latest time stamp. 6) File size of original cobertura.ser and updated cobertura.ser is same, but with updated time stamp. 7) I grab this latest updated cobertura.ser file to create my reports. And i see over all* 4%* coverage report and sometimes get *12%* coverage. We are expecting at least more than 60% coverage at this time. *Am i using the correct cobertura.ser file for generating coverage report?.* Or from the cobertura document at below link, http://cobertura.sourceforge.net/faq.html , under heading *Using Cobertura with a Web Application*, i read the following. After deploy the war file into your application server (Tomcat, JBoss, WebLogic, WebSphere, etc). and run your tests. will create a "cobertura.ser" file on the disk. You may need to dig around a bit to find it. Cobertura puts this file in what it considers to be the current working directory. Typically this is the directory that the application server was started from (for example, C:\Tomcat\bin). *I have below questions.* a) Is this means, another cobertura.ser file will be getting created on the *AIX server ( this is the server my application is running)* running in an external server box directory apart from the cobertura.ser file getting created in my local *C:\WorkingDir* .? And do i need to go to server, stop the server and grab another cobertura.ser and merge with cobertura.ser created on my working directory and use in my report generation. to get good coverage report? b) Or there is only one cobertura.ser file will be created over all, that is only in *C:\WorkingDir, *that * *i need to use in coverage report to see good code coverage results.? This is very confusing to me. Your inputs or any body from the groups have any pointers, suggestions will be of great help. Thank you. Sakthi. On Thu, Jul 26, 2012 at 12:03 AM, *** From Sakthivel Kumar*** < nsa...@gm...> wrote: > John: > > As you mentioned in your below notes, after instrumentation, I fully > searched my C drive, i do not see a cobertura.ser file that is created > after code instrumentation is done. > Below is the BuildInstument.Xml i used to for code instrumentation. Please > take a look and let me know if something is wrong. Also provide me a sample > working instrument build file that creates cobertura.ser file. > > I appreciate your help and time. > > Thanks in advance > Sakthi > > <?xml version="1.0" encoding="UTF-8"?> > > <project name="cobertura.examples.basic" default="InstrumentQReads" > basedir="."> > > <description> > Cobertura - http://cobertura.sourceforge.net/ > </description> > > <property file="build.properties" /> > > > <!-- cobertura task definition --> > <path id="cobertura.classpath"> > <fileset dir="${cobertura.dir}"> > <include name="cobertura.jar" /> > <include name="lib/**/*.jar" /> > </fileset> > </path> > > <taskdef classpathref="cobertura.classpath" > resource="tasks.properties"/> > > > <target name="init"> > <echo message="MHD: Inside ... init of InstrumentQReads..."/> > <mkdir dir="${classes.dir}" /> > <mkdir dir="${instrumented.dir}" /> > <echo message="MHD: Done... init of InstrumentQReads."/> > </target> > > > <target name="compile" depends="init"> > <echo message="MHD: Inside ... compile of InstrumentQReads..."/> > <javac srcdir="${src.dir}" destdir="${classes.dir}" debug="true" > debuglevel="vars,lines,source" > > <classpath refid="cobertura.classpath" /> > </javac> > <echo message="MHD: Done... compile of InstrumentQReads..."/> > </target> > > <target name="instrument" depends="init,compile" > > <echo message="MHD: Doing instrumentation for jar files."/> > <!-- > Remove the coverage data file and any old instrumentation. > --> > <delete file="cobertura.ser"/> > > <!-- delete dir="${instrumented.dir}" / --> > > <!-- > Instrument the application jars, writing the instrumented > jars, in to ${build.instrumented.dir}. > --> > > <cobertura-instrument datafile="${reports.dir}/basic_coverage.ser" > todir="${instrumented.dir}"> > <!-- The following line causes instrument to ignore any source > line containing a reference to log4j, for the purposes of coverage > reporting.--> > <ignore regex="org.apache.log4j.*" /> > > <fileset dir="${jars.dir}"> > <include name="**/*.jar" /> > </fileset> > </cobertura-instrument> > <echo message="MHD: done instrumentation of jar Files."/> > </target> > > <target name="test" depends="init,compile"> > > <junit fork="yes" dir="${basedir}" failureProperty="test.failed"> > <!-- > Specify the name of the coverage data file to use. > The value specified below is the default. > --> > <sysproperty key="net.sourceforge.cobertura.datafile" > file="${basedir}/cobertura.ser" /> > > <!-- > Note the classpath order: instrumented classes are before > the > original (uninstrumented) classes. This is important. > --> > > <classpath location="${instrumented.dir}" /> > > <!-- > The instrumented classes reference classes used by the > Cobertura runtime, so Cobertura and its dependencies > must be on your classpath. > > > <classpath refid="cobertura_classpath" /> > > <formatter type="xml" /> > <test name="${testcase}" todir="${reports.xml.dir}" if="testcase" /> > <batchtest todir="${reports.xml.dir}" unless="testcase"> > <fileset dir="${src.dir}"> > <include name="**/*Test.java" /> > </fileset> > </batchtest> > > --> > > </junit> > > </target> > > > <target name="InstrumentQReads" depends="instrument,compile,test" > description="Compile and instrument QReads jar files."/> > > </project> > > > On Thu, May 24, 2012 at 11:16 AM, John W. Lewis <Joh...@sa...>wrote: > >> ** ** >> >> That almost always means that your tests are not using the cobertura.ser >> file that is created during the instrumentation. You have to make sure >> that the cobertura.ser file is moved to the working directory of your >> tests, or use the cobertura property (as described in the Cobertura Ant >> documentation) to point to the cobertura.ser file.**** >> >> ** ** >> >> ** ** >> >> *From:* Ionel Pagu [mailto:Ion...@te...] >> *Sent:* Thursday, May 24, 2012 11:54 AM >> *To:* cob...@li... >> *Subject:* [Cobertura-devel] coverage not reported properly on the main >> page**** >> >> ** ** >> >> Hi,**** >> >> **** >> >> After tweaking the ant scripts a bit, I was now able to instrument, run >> our jUnits and then run the report successfully. However, there is one odd >> thing: in the main report page, the coverage is reported as 100% everywhere >> but I know our jUnits are not that good. Even further, if I click the links >> to check source code I can clearly see code not being (fully) covered. So >> now I am puzzled. The tools seems to detect that properly but not summarize >> it correctly.**** >> >> **** >> >> Any idea?**** >> >> **** >> >> Thanks,**** >> >> *Ionel Pagu***** >> >> The information in this e-mail is confidential and may be legally >> privileged. >> It is intended solely for the addressee. Access to this e-mail by anyone >> else is unauthorized. **** >> >> >> ------------------------------------------------------------------------------ >> Live Security Virtual Conference >> Exclusive live event will cover all the ways today's security and >> threat landscape has changed and how IT managers can respond. Discussions >> will include endpoint security, mobile security and the latest in malware >> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ >> _______________________________________________ >> Cobertura-devel mailing list >> Cob...@li... >> https://lists.sourceforge.net/lists/listinfo/cobertura-devel >> >> > > > -- > Thanks and Best Regards > > Sakthivel Kumar > > nsa...@gm... > -- Thanks and Best Regards Sakthivel Kumar nsa...@gm... |