diff --git a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java index a6faaf3f1..8a4ab2e51 100644 --- a/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java +++ b/pitest-html-report/src/main/java/org/pitest/mutationtest/report/html/MutationTestSummaryData.java @@ -20,15 +20,18 @@ import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; +import java.util.Iterator; import java.util.Set; import java.util.TreeSet; import java.util.function.BiFunction; import java.util.function.Function; +import java.util.logging.Level; import org.pitest.classinfo.ClassInfo; import org.pitest.coverage.TestInfo; import org.pitest.functional.FCollection; import org.pitest.mutationtest.MutationResult; +import org.pitest.util.Log; public class MutationTestSummaryData { @@ -62,8 +65,16 @@ public MutationTotals getTotals() { } public String getPackageName() { - final String packageName = getMutatedClasses().iterator().next().getName() - .asJavaName(); + Iterator iterator = getMutatedClasses().iterator(); + if (!iterator.hasNext()) { + Log.getLogger().log(Level.WARNING, "Can't get package name for " + fileName + "." + + "There is no mutated classes. It may happen if you are using report-aggregate " + + "goal to merge reports using a dedicated maven project " + + "and the dependency that contains the mutated code is missing"); + return "default"; + } + final String packageName = iterator.next().getName() + .asJavaName(); final int lastDot = packageName.lastIndexOf('.'); return lastDot > 0 ? packageName.substring(0, lastDot) : "default"; }