/hg/MauveTestCoverage: * src/ReportGenerator.java:
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue May 15 08:47:30 PDT 2012
changeset ed99188fff20 in /hg/MauveTestCoverage
details: http://icedtea.classpath.org/hg/MauveTestCoverage?cmd=changeset;node=ed99188fff20
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue May 15 17:50:12 2012 +0200
* src/ReportGenerator.java:
Fixed the code which is used to count the number of tested
classes in a given package.
diffstat:
ChangeLog | 6 ++++++
src/ReportGenerator.java | 31 ++++++++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletions(-)
diffs (61 lines):
diff -r eec2474fdaaa -r ed99188fff20 ChangeLog
--- a/ChangeLog Fri Mar 23 11:55:40 2012 +0100
+++ b/ChangeLog Tue May 15 17:50:12 2012 +0200
@@ -1,3 +1,9 @@
+2012-05-15 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/ReportGenerator.java:
+ Fixed the code which is used to count the number of tested
+ classes in a given package.
+
2012-03-23 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/ClassInfo.java:
diff -r eec2474fdaaa -r ed99188fff20 src/ReportGenerator.java
--- a/src/ReportGenerator.java Fri Mar 23 11:55:40 2012 +0100
+++ b/src/ReportGenerator.java Tue May 15 17:50:12 2012 +0200
@@ -216,7 +216,7 @@
// compute number of all classes in a package
final int allClassesCnt = numberOfClassesInPackage(packageName, allClasses);
// compute number of classes covered by tests
- final int testedClassesCnt = numberOfClassesInPackage(packageName, testedClasses);
+ final int testedClassesCnt = numberOfTestedClassesInPackage(packageName, testedClasses, classInfoMap);
// -> in percent
final float classPercentage = allClassesCnt == 0 ? 0.0f : 100.0f * testedClassesCnt / allClassesCnt;
// table row background color is based on percentual test coverage ration
@@ -300,6 +300,35 @@
}
/**
+ * Calculate number of tested classes in given package.
+ *
+ * @param packageName
+ * name of package
+ * @param classes
+ * set of class names
+ * @param classInfoMap
+ * @return number of classes in given package
+ */
+ private static int numberOfTestedClassesInPackage(String packageName, Set<String> classes, Map<String, ClassInfo> classInfoMap)
+ {
+ int cnt = 0;
+ // iterate through all class names
+ for (String className : classes)
+ {
+ // count only classes in given package
+ if (className.substring(0, className.lastIndexOf('.')).equals(packageName))
+ {
+ ClassInfo clsInfo = classInfoMap.get(className);
+ if (clsInfo != null && !clsInfo.getTestedMethods().isEmpty())
+ {
+ cnt++;
+ }
+ }
+ }
+ return cnt;
+ }
+
+ /**
* Add list of all classes to a list of string which represents generated
* report.
*
More information about the distro-pkg-dev
mailing list