From: Mark D. <Mar...@sa...> - 2005-06-01 16:54:50
|
Hi! Hopefully we've fixed this in CVS. The way it's supposed to work now = is, you merge two ProjectData classes together, which recursively merges = all PackageData classes, which merges all SourceFileData classes, which = merges all ClassData classes, which merges all LineData classes (by = summing the hit counts for each line). -Mark > -----Original Message----- > From: cob...@li...=20 > [mailto:cob...@li...] On=20 > Behalf Of Harish Prabhakara > Sent: Wednesday, May 18, 2005 12:18 PM > To: cob...@li... > Subject: [Cobertura-devel] bug while merging >=20 > hi, >=20 > We are trying to merge two cobertura.ser files which has the=20 > same code base. > one cobertura.ser files is created when running junit and=20 > the other is > created when weblogic server is stopped which are created in=20 > two different > directories. > Apparently when trying to merge we found that it is just=20 > overwriting the > other. for e.g. Junit calls a Delegate class which happens to=20 > have a code > coverage of 40%. > This Delegate class calls the server classes and no Delegate=20 > class is called > through the server. So the code coverage for this Delegate=20 > class is 0% in > the cobertura.ser > generated by the weblogic. >=20 > Now when we are trying to merge this both ideally it should=20 > been given 40% > but it gives 0%. Going through the source code we found that in > CoverageData.java > we have a method which merges the two files as given below.=20 > public void merge(CoverageData coverageData) > { lines.putAll(coverageData.lines); > conditionals.putAll(coverageData.conditionals); > methodNamesAndDescriptors.addAll(coverageData > .getMethodNamesAndDescriptors()); > } > In the above code lines is a HashMap object >=20 > The lines.putAll(coverageData.lines) just overwrites the data.=20 >=20 > The above method could be modified as given below. >=20 > public void merge(CoverageData coverageData) > { Set keySet =3D lines. keySet(); >=20 > Iterator iterator =3D keySet.iterator(); > while(iterator.hasNext()) { > Integer lineNumber =3D (Integer) iterator.next(); > LineInformation l1 =3D > (LineInformation)lines.get(lineNumber); > LineInformation l2 =3D > (LineInformation)coverageData.lines.get(lineNumber); > long hits1 =3D l1.getHits(); > long hits2 =3D l2.getHits(); >=20 > if(hits2>hits1) { > lines.put(lineNumber,l2); > } > } >=20 > //lines.putAll(coverageData.lines); > conditionals.putAll(coverageData.conditionals); > methodNamesAndDescriptors.addAll(coverageData > .getMethodNamesAndDescriptors()); > } >=20 >=20 > Let me know if anyone has a better solution. >=20 > Regards > Harish >=20 >=20 >=20 >=20 > > -----Original Message----- > > From: Harish Prabhakara =20 > > Sent: Tuesday, May 17, 2005 4:04 PM > > To: 'cob...@li...' > > Cc: Iyer, Tejas; Satyadarshi Mishra; Bothra, Naveen > > Subject: improper codecoverage report > >=20 > > hi, > >=20 > > We are trying to do a code coverage analysis for an=20 > application deployed > > under Weblogic 8.1 server. The application is been tested > > using Junit as well as HttpUnit Test Cases. While doing the=20 > code coverage > > analysis we found that the code coverage is been > > reported for those classes which has been called through Junit. Code > > coverage for those Classes which are run under Weblogic=20 > > environment or under HttpUnit environment is not shown as=20 > covered. For > > E.g. Let us say that we have got a Delegate class > > which calls a service. This service is an EJB which is=20 > been deployed in > > the Weblogic server. This Ejb in turns calls some VOAssembler=20 > > classes and in turn calls the DAO classes.=20 > >=20 > >=20 > > The test case calls the SiteDelegate which internally finds=20 > the service > > and executes the service.=20 > >=20 > > The build.xml does exactly as mentioned in the documentation. > >=20 > > set the classpath for the cobertura.jar. > > compile the java files. > > Create instrumented classes over the compilation classes > > set the classpath for the instrumented classes > > run the testcase > > create the report. > >=20 > > On analysis of the report, we could find code coverage only=20 > for delegate > > class and there no coverage is been reported for other classes such > > as EJB, VOAssembler and DAO.=20 > >=20 > >=20 > > Kindly can you help in resolving this problem. > >=20 > > Thanks and Regards > > Harish > >=20 |