Code coverage by Cobertura

32 views
Skip to first unread message

Fati Ahmadi

unread,
Jan 20, 2017, 3:42:24 AM1/20/17
to SonarQube
Hi Guys,

Would somebody help me to understand the functionality of Cobertura in the link  below related to Flex language


for the lines 6,7,8 in the file Circle.as  below a xml coverage  file is provided which hits this ines by 1.
package {
public class Circle {
public var diameter:int = 0;
6 function Circle (d:int) {
7 this.diameter = d;
8 }
}
}

As it displayed in the link line 6,7,8 for Circle.as have value '1' 
<lines>
<line number="6" hits="1" branch="false"/>
<line number="7" hits="1" branch="false"/>
<line number="8" hits="1" branch="false"/>
</lines>

After running lines 6,7,8 will be green, 100% coverage.

Mijn question:

1- Is this xml file provided by the user?
2- there is no test file for Circle.as how is this percentage  calculated by Cobertura? in eclipse Cobertura finds the lines in the code which are not tested in unit test. How does it work hier?

3- the user is able to manage xml file , if i hits the whole code by 1  then the result will be 100 % coverage. 
What doest it make sense? It looks that Cobertura  measures what the user defines as 1 or 0 in the xml file not the code.


Many thanks,
Fati

Michel Pawlak

unread,
Jan 20, 2017, 6:44:17 AM1/20/17
to SonarQube
Hi,

I'm not working on the flex plugin. However:
  • the XML file is not provided by the user, it should be generated by Cobertura
  • if the XML file is in the source repository it means that it has been committed by mistake
  • if there is no test file for Circle.as, maybe there was another piece of code that uses Circle.as that was correctly tested when the report file was committed. 
  • you're right, if someone manages forging or tempering with the content of reports files, measures will be wrong. However if you run a coverage analysis from scratch on the project, what will be displayed then ?
Regards,

Michel
Reply all
Reply to author
Forward
0 new messages