jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
Signup
Maven 1.x JCoverage Plugin
  • Maven 1.x JCoverage Plugin
  • MPJCOVERAGE-14

Invalid Overview and packages rates

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.0.7
  • Fix Version/s: 1.0.8
  • Labels:
    None
  • Environment:
    Maven 1.0 jcoverage 1.0.5
  • Number of attachments :
    2

Description

First, please excuse me for my poor English.

Maven jcoverage plugins generate an html report using xml data generated by jcoverage.

The overwiew and packages rates are not the sames as with jcoverage alone. This difference is due to the maven plugin algorythm wich ignores the "weight" (number of lines) of the classes.

If a package contains two classes one which contains 200 lines is tested at 80% and an other wich contains 10 lines tested at 0%, the plugin will compute a package rate of 40%, jcoverage alone will compute a rate of 76%.

I have modified the plugin in order to compute the good rates.

Here are the changes :

Coverage.java :

public String getCoveredPercentBranch()
{
double totalLines = 0.00d;
double total = 0.00d;

if (getLineCoverage() > 0.00d)
{
for (Iterator iter = getClasses().iterator(); iter.hasNext(); )
{
Clazz theClass = (Clazz) iter.next();
int classLines = theClass.getLines().size();
double rate = 0;
try

{ rate = new Double(theClass.getBranchRate()).floatValue(); }
catch(NumberFormatException e)
{ rate = 0; }
total += (rate*classLines);
totalLines += classLines;
}

total /= totalLines;
}

return String.valueOf(total);
}

private double getLineCoverage()
{
double totalLines = 0.00d;
double totalTestedLines = 0.00d;
for (Iterator iter = getClasses().iterator(); iter.hasNext(); )
{
Clazz theClass = (Clazz) iter.next();
int classLines = theClass.getLines().size();
double rate = 0;
try
{ rate = new Double(theClass.getLineRate()).floatValue(); }
catch(NumberFormatException e)
{ rate = 0; }
totalTestedLines += (rate * classLines);
totalLines += classLines;
}

return (totalTestedLines / totalLines);

}

Package.java :

public String getCoveredPercentBranch()
{
double pckgLines = 0.00d;
double total = 0.00d;

if (getLineCoverage() > 0.00d)
{
for (Iterator iter = getClasses().iterator(); iter.hasNext(); )
{
Clazz theClass = (Clazz) iter.next();
int classLines = theClass.getLines().size();
double rate = 0;
try
{ rate = new Double(theClass.getBranchRate()).floatValue(); }

catch(NumberFormatException e)

{ rate = 0; }

total += (rate*classLines);
pckgLines += classLines;
}

total /= pckgLines;
}

return String.valueOf(total);
}

private double getLineCoverage()
{
double pckgLines = 0.00d;
double pckgTestedLines = 0.00d;
for (Iterator iter = getClasses().iterator(); iter.hasNext(); )
{
Clazz theClass = (Clazz) iter.next();
int classLines = theClass.getLines().size();
double rate = 0;
try

{ rate = new Double(theClass.getLineRate()).floatValue(); }

catch(NumberFormatException e)

{ rate = 0; }

pckgTestedLines += (rate * classLines);
pckgLines += classLines;
}

return (pckgTestedLines / pckgLines);
}

May be branches rates could be "weighted" by the number of branches and not by the number of lines.

Thanks, Thomas

  • Options
    • Sort By Name
    • Sort By Date
    • Ascending
    • Descending
    • Download All

Attachments

  1. Java Source File
    Coverage.java
    02/Sep/04 1:09 PM
    5 kB
    Thomas Recloux
  2. Java Source File
    Package.java
    02/Sep/04 1:09 PM
    4 kB
    Thomas Recloux

Activity

  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Emmanuel Venisse added a comment - 03/Sep/04 4:05 AM

Applied. Thanks.

Show
Emmanuel Venisse added a comment - 03/Sep/04 4:05 AM Applied. Thanks.

People

  • Assignee:
    Emmanuel Venisse
    Reporter:
    Thomas Recloux
Vote (0)
Watch (1)

Dates

  • Created:
    02/Sep/04 1:07 PM
    Updated:
    03/Sep/04 4:05 AM
    Resolved:
    03/Sep/04 4:05 AM

Time Tracking

Estimated:
30m
Original Estimate - 30 minutes
Remaining:
30m
Remaining Estimate - 30 minutes
Logged:
Not Specified
Time Spent - Not Specified
  • Atlassian JIRA (v5.2.7#850-sha1:b2af0c8)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.