private Map<InputFile, UnitTestClassReport> mapToInputFile(Map<String, UnitTestClassReport> indexByClassname) { Map<InputFile, UnitTestClassReport> result = new HashMap<>(); indexByClassname.forEach((className, index) -> { InputFile resource = getUnitTestResource(className, index); if (resource != null) { UnitTestClassReport report = result.computeIfAbsent(resource, r -> new UnitTestClassReport()); // in case of repeated/parameterized tests (JUnit 5.x) we may end up with tests having the same name index.getResults().forEach(report::add); } else { LOGGER.debug("Resource not found: {}", className); } }); return result; }
private Map<InputFile, UnitTestClassReport> mapToInputFile(Map<String, UnitTestClassReport> indexByClassname) { Map<InputFile, UnitTestClassReport> result = new HashMap<>(); indexByClassname.forEach((className, index) -> { InputFile resource = getUnitTestResource(className, index); if (resource != null) { UnitTestClassReport report = result.computeIfAbsent(resource, r -> new UnitTestClassReport()); // in case of repeated/parameterized tests (JUnit 5.x) we may end up with tests having the same name index.getResults().forEach(report::add); } else { LOGGER.debug("Resource not found: {}", className); } }); return result; }
private void save(UnitTestIndex index, SensorContext context) { long negativeTimeTestNumber = 0; for (Map.Entry<String, UnitTestClassReport> entry : index.getIndexByClassname().entrySet()) { UnitTestClassReport report = entry.getValue(); if (report.getTests() > 0) { negativeTimeTestNumber += report.getNegativeTimeTestNumber(); Resource resource = getUnitTestResource(entry.getKey()); if (resource != null) { save(report, resource, context); } else { LOGGER.warn("Resource not found: {}", entry.getKey()); } } } if (negativeTimeTestNumber > 0) { LOGGER.warn("There is {} test(s) reported with negative time by surefire, total duration may not be accurate.", negativeTimeTestNumber); } }