diff --git a/junit/src/org/netbeans/modules/junit/output/JUnitOutputReader.java b/junit/src/org/netbeans/modules/junit/output/JUnitOutputReader.java --- a/junit/src/org/netbeans/modules/junit/output/JUnitOutputReader.java +++ b/junit/src/org/netbeans/modules/junit/output/JUnitOutputReader.java @@ -553,6 +553,7 @@ if ((reportFile != null) && isValidReportFile(reportFile)) { JUnitTestSuite reportSuite = parseReportFile(reportFile); if ((reportSuite != null) && (reportSuite.getName().equals(currentSuite.getName()))) { + deleteReportFile(reportFile); // #171050 lastSuiteTime = reportSuite.getElapsedTime(); for(Testcase tc: currentSuite.getTestcases()){ if (!tc.getOutput().isEmpty()){ @@ -739,6 +740,23 @@ return false; } } + + private void deleteReportFile(File reportFile) { + try { + reportFile = FileUtil.normalizeFile(reportFile); + String reportPath = reportFile.getAbsolutePath(); + reportPath = reportPath.replace('\\', '/'); + String projectPath = + testSession.getProject().getProjectDirectory().getPath(); + if (reportPath.startsWith(projectPath)) { + // we won't delete not temporary report located in project + return; + } + reportFile.delete(); + } catch (Exception e) { + // do nothing + } + } private File findReportFile() { File file = new File(resultsDir,