Message:

  A new issue has been created in JIRA.

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/browse/MPJCOVERAGE-14

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: MPJCOVERAGE-14
    Summary: Invalid Overview and packages rates
       Type: Bug

     Status: Open
   Priority: Major

 Original Estimate: 30 minutes
 Time Spent: Unknown
  Remaining: 30 minutes

    Project: maven-jcoverage-plugin
   Versions:
             1.0.7

   Assignee: Emmanuel Venisse
   Reporter: Thomas Recloux

    Created: Thu, 2 Sep 2004 1:07 PM
    Updated: Thu, 2 Sep 2004 1:07 PM
Environment: Maven 1.0 jcoverage 1.0.5

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


---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to