Mercurial > hg > MauveTestCoverage
changeset 20:50271ecf8de5 draft
Make sure that report generator does not throw NPE.
author | Pavel Tisnovsky <ptisnovs@redhat.com> |
---|---|
date | Mon, 20 Aug 2012 17:32:13 +0200 |
parents | 7bb9210fb192 |
children | 7cd98b5c3440 |
files | ChangeLog src/ReportGenerator.java |
diffstat | 2 files changed, 19 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Jun 15 17:33:08 2012 +0200 +++ b/ChangeLog Mon Aug 20 17:32:13 2012 +0200 @@ -1,3 +1,8 @@ +2012-08-20 Pavel Tisnovsky <ptisnovs@redhat.com> + + * src/ReportGenerator.java: + Make sure that report generator does not throw NPE. + 2012-06-15 Pavel Tisnovsky <ptisnovs@redhat.com> * Makefile:
--- a/src/ReportGenerator.java Fri Jun 15 17:33:08 2012 +0200 +++ b/src/ReportGenerator.java Mon Aug 20 17:32:13 2012 +0200 @@ -406,6 +406,11 @@ */ private static String addOneRowToResultsTable(String reportDirectory, String className, Map<String, ClassInfo> classInfoMap) { + // check if class is processed at all + if (!classInfoMap.containsKey(className)) + { + return ""; + } Set<String> apiMethods = classInfoMap.get(className).getApiMethods(); Set<String> testedMethods = classInfoMap.get(className).getTestedMethods(); // compute number of all methods in a class @@ -616,11 +621,15 @@ // iterate through all tested classes for (String testedClass : testedClasses) { - ClassInfo classInfo = classInfoMap.get(testedClass); - Set<String> apiMethods = classInfo.getApiMethods(); - Set<String> testedMethods = classInfo.getTestedMethods(); - Set<String> allMethods = classInfo.getAllMethods(); - createFileForClass(reportDirectory, testedClass, allMethods, apiMethods, testedMethods); + // tested class should exists + if (classInfoMap.containsKey(testedClass)) + { + ClassInfo classInfo = classInfoMap.get(testedClass); + Set<String> apiMethods = classInfo.getApiMethods(); + Set<String> testedMethods = classInfo.getTestedMethods(); + Set<String> allMethods = classInfo.getAllMethods(); + createFileForClass(reportDirectory, testedClass, allMethods, apiMethods, testedMethods); + } } }