diff --git a/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java b/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java index 6bb783d02..f5f217b43 100644 --- a/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java +++ b/pitest-aggregator/src/main/java/org/pitest/aggregate/ReportAggregator.java @@ -159,7 +159,11 @@ public Builder lineCoverageFiles(final List lineCoverageFiles) { public Builder addLineCoverageFile(final File lineCoverageFile) { validateFile(lineCoverageFile); - this.lineCoverageFiles.add(lineCoverageFile); + if (lineCoverageFile.exists()) { + this.lineCoverageFiles.add(lineCoverageFile); + } else { + LOG.info("ignoring absent line coverage file " + lineCoverageFile.getAbsolutePath()); + } return this; } @@ -173,7 +177,11 @@ public Builder mutationResultsFiles(final List mutationResultsFiles) { public Builder addMutationResultsFile(final File mutationResultsFile) { validateFile(mutationResultsFile); - this.mutationResultsFiles.add(mutationResultsFile); + if (mutationResultsFile.exists()) { + this.mutationResultsFiles.add(mutationResultsFile); + } else { + LOG.info("ignoring absent mutation results file " + mutationResultsFile.getAbsolutePath()); + } return this; } @@ -273,8 +281,9 @@ private void validateFile(final File file) { if (file == null) { throw new IllegalArgumentException("file is null"); } - if (!file.exists() || !file.isFile()) { - throw new IllegalArgumentException(file.getAbsolutePath() + " does not exist or is not a file"); + // a non existent file shouldn't prevent the aggregator from being built + if (file.exists() && !file.isFile()) { + throw new IllegalArgumentException(file.getAbsolutePath() + "is not a file"); } } diff --git a/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java b/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java index 0f4905833..26e420097 100644 --- a/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java +++ b/pitest-aggregator/src/test/java/org/pitest/aggregate/ReportAggregatorBuilderTest.java @@ -22,7 +22,7 @@ public class ReportAggregatorBuilderTest { - private static final String NOT_A_FILE = "does not exist or is not a file"; + private static final String NOT_A_FILE = "is not a file"; private static final String NOT_A_DIR = "is not a directory"; private static final String IS_NULL = "is null"; @Rule @@ -38,10 +38,10 @@ public void testLineCoverageFiles_withNull() { @Test public void testLineCoverageFiles_withFake() { - this.expected.expect(IllegalArgumentException.class); - this.expected.expectMessage(Matchers.containsString(NOT_A_FILE)); + ReportAggregator.Builder builder = ReportAggregator.builder() + .lineCoverageFiles(Arrays.asList(new File("doesnotexist.xml"))); - ReportAggregator.builder().lineCoverageFiles(Arrays.asList(new File("doesnotexist.xml"))); + assertTrue(builder.getMutationResultsFiles().isEmpty()); } @Test @@ -62,10 +62,10 @@ public void testMutationResultsFiles_withNull() { @Test public void testMutationResultsFiles_withFake() { - this.expected.expect(IllegalArgumentException.class); - this.expected.expectMessage(Matchers.containsString(NOT_A_FILE)); + ReportAggregator.Builder builder = ReportAggregator.builder() + .mutationResultsFiles(Arrays.asList(new File("doesnotexist.xml"))); - ReportAggregator.builder().mutationResultsFiles(Arrays.asList(new File("doesnotexist.xml"))); + assertTrue(builder.getMutationResultsFiles().isEmpty()); } @Test