CoverageResultImporter extends SingleFileReportImporter { @Override protected void importReport(File coverageReportFile, SensorContext context) { LOG.debug("Parsing file: " + coverageReportFile.getAbsolutePath()); parseFile(coverageReportFile, context); } CoverageResultImporter(String reportPathKey, String msg); static ReportImporter multiCoverageImporter();  }
@Test public void should_throw_an_exception_when_report_not_found() { thrown.expect(IllegalStateException.class); thrown.expectMessage("Can't read phpUnit report:"); importer.importReport(new File("notfound.txt"), setUpForMockedSensorContext()); }
@Test public void should_parse_even_with_package_node() throws Exception { String componentKey = componentKey(MONKEY_FILE_NAME); importer.importReport(getReportsWithAbsolutePath("phpunit.coverage-with-package.xml"), context); assertCoverageLineHits(context, componentKey, 34, 1); }
@Test public void should_generate_coverage_measures() throws Exception { String componentKey = "moduleKey:" + MONKEY_FILE_NAME; importer.importReport(getReportsWithAbsolutePath("phpunit.coverage.xml"), context); assertReport(componentKey); }
@Test public void should_work_with_relative_paths() throws Exception { String componentKey = componentKey(MONKEY_FILE_NAME); String reportName = "phpunit.coverage.xml"; File reportFile = Paths.get(SRC_TEST_RESOURCES, PhpTestUtils.PHPUNIT_REPORT_DIR, reportName).toFile(); importer.importReport(reportFile, context); assertReport(componentKey); }
@Test public void should_not_fail_if_no_statement_count() throws Exception { String componentKey = componentKey(MONKEY_FILE_NAME); importer.importReport(getReportsWithAbsolutePath("phpunit.coverage-with-no-statements-covered.xml"), context); assertCoverageLineHits(context, componentKey, 31, 0); }
@Test public void should_not_fail_if_no_line_for_file_node() throws Exception { try { importer.importReport(getReportsWithAbsolutePath("phpunit.coverage-with-filenode-without-line.xml"), context); } catch (Exception e) { fail("Shound never happen"); } }
@Test public void should_not_set_metrics_to_ncloc_for_missing_files_sq_62() throws Exception { String componentKey = componentKey("Monkey.php"); importer.importReport(getReportsWithAbsolutePath("phpunit.coverage-empty.xml"), context); assertThat(context.measure(componentKey, CoreMetrics.LINES_TO_COVER)).isNull(); assertThat(context.measure(componentKey, CoreMetrics.UNCOVERED_LINES)).isNull(); }