Hello
When I run tests, I get a clover.xml file that contains tags and attributes like this:
<metrics conditionals="664" methods="117" classes="13" files="9" packages="1" coveredstatements="1554" complexity="710" loc="3620" ncloc="3203" coveredmethods="105" coveredconditionals="479" statements="1989" coveredelements="2138" elements="2770"/>
Among the attributes, we find methods and coveredmethods, statements and coveredstatements, ...
I'm interested in number of code lines, and the number of covered code lines.
Is there a way to have them in clover.xml, preferably in the same metrics tag?
Thanks in advance..
loc
=
"3620" is the number for Lines Of Code.
I think that ncloc
=
"3203" is the number for N
on-Comment Lines of Code as per https://confluence.atlassian.com/display/CLOVER/clover-report
Actually there is no point in "Covered Lines of Code" number. "Covered Statements" is very well describing the coverage.
Cheers,
Jacek
I see.
But can you please further explain why "cover lines of code" number is not a good metric for coverage? An example would be very appreciated.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I see.
But can you please further explain why "cover lines of code" number is not a good metric for coverage? An example would be very appreciated.
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There are 3620 lines of code. Comments and empty lines cannot be covered so we can only consider lines with the real code to cover.
You have 1989 statements. Some of them probably span multiple lines so let's assume there are 2000 lines of code containing statements.
Next let's assume that all your code is covered (all 1989 statemetns and thus all 2000 lines). It means that your code is fully covered (1989 statements in total / 1989 statements covered = 100%). This is very good existing metric.
On the other hand there are: 2000 lines with code covered / 3620 lines in total = 55%. If you add more comments or empty lines (e.g. licensing information) then the number will drop below 55% while still all your code will be covered.
This 55% simply says nothing.
In order to make it reasonable we would need to find "number of lines containing statements" and compare with "number of covered lines containing statements" to get meaningfull 100% - but this is actually duplicate of what we have now: number of statements and number of covered statements.
Does this answer your question?
Cheers,
Jacek
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.