MPJCOVERAGE-14. Fixed overview and packages rates.

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@116027 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
evenisse 2004-09-03 07:58:59 +00:00
parent 04d2f2d0e7
commit 6fe877be14
3 changed files with 34 additions and 18 deletions

View File

@ -26,7 +26,7 @@ import java.util.HashMap;
/**
* @author Emmanuel Venisse
* @version $Id: Coverage.java,v 1.4 2004/03/06 22:41:56 evenisse Exp $
* @version $Id: Coverage.java,v 1.5 2004/09/03 07:58:59 evenisse Exp $
*/
public class Coverage
{
@ -123,13 +123,15 @@ public class Coverage
public String getCoveredPercentBranch()
{
double total = 0.00d;
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
{
@ -139,30 +141,38 @@ public class Coverage
{
rate = 0;
}
total += rate;
total += (rate*classLines);
totalLines += classLines;
}
total /= totalLines;
}
return String.valueOf(total / getClasses().size());
return String.valueOf(total);
}
private double getLineCoverage()
{
double total = 0.00d;
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;
}
total += rate;
totalTestedLines += (rate * classLines);
totalLines += classLines;
}
return total / getClasses().size();
return (totalTestedLines / totalLines);
}
}

View File

@ -24,7 +24,7 @@ import java.util.List;
/**
* @author Emmanuel Venisse
* @version $Id: Package.java,v 1.5 2004/03/06 22:41:56 evenisse Exp $
* @version $Id: Package.java,v 1.6 2004/09/03 07:58:59 evenisse Exp $
*/
public class Package
{
@ -91,13 +91,15 @@ public class Package
public String getCoveredPercentBranch()
{
double total = 0.00d;
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
{
@ -107,10 +109,11 @@ public class Package
{
rate = 0;
}
total += rate;
total += (rate*classLines);
pckgLines += classLines;
}
total /= getClasses().size();
total /= pckgLines;
}
return String.valueOf(total);
@ -118,23 +121,25 @@ public class Package
private double getLineCoverage()
{
double total = 0.00d;
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;
}
total += rate;
pckgTestedLines += (rate * classLines);
pckgLines += classLines;
}
return (total / getClasses().size());
return (pckgTestedLines / pckgLines);
}
}

View File

@ -25,6 +25,7 @@
</properties>
<body>
<release version="1.0.8" date="In CVS">
<action dev="evenisse" type="fix" issue="MPJCOVERAGE-14">Fixed overview and packages rates.</action>
<action dev="evenisse" type="add">Add the possibility to set multiple includes and excludes files for instrumentation.</action>
</release>
<release version="1.0.7" date="2004-07-11">