JUnitLogParserForPhpUnit { public TestSuites parse(File report) { try { return processRoot(report, inputFactory()); } catch (XMLStreamException e) { throw new IllegalStateException("Can't read PhpUnit report : " + report.getAbsolutePath(), e); } }  TestSuites parse(File report); static SMInputFactory inputFactory();  }
@Test public void shouldGenerateEmptyTestSuites() { final TestSuites suites = parser.parse(new File("src/test/resources/" + PhpTestUtils.PHPUNIT_REPORT_DIR + "phpunit-with-empty-testsuites.xml")); assertThat(suites).isEqualTo(new TestSuites(Collections.emptyList())); }
@Test public void shouldParseTestSuitesWithoutTime() { final TestSuites suites = parser.parse(new File("src/test/resources/" + PhpTestUtils.PHPUNIT_REPORT_DIR + "phpunit-junit-report-no-time.xml")); assertThat(suites).isNotNull(); List<TestFileReport> reports = suites.arrangeSuitesIntoTestFileReports(); assertThat(reports).hasSize(2); assertThat(reports.get(0).testDurationMilliseconds()).isEqualTo(0); assertThat(reports.get(1).testDurationMilliseconds()).isEqualTo(0); }
@Test(expected = IllegalStateException.class) public void shouldThrowAnExceptionWhenReportIsInvalid() { parser.parse(new File("src/test/resources/" + PhpTestUtils.PHPUNIT_REPORT_DIR + "phpunit-invalid.xml")); }
@Test(expected = IllegalStateException.class) public void shouldThrowAnExceptionWhenReportDoesNotExist() throws Exception { parser.parse(new File("target/unexistingFile.xml")); }
@Test public void shouldParseComplexNestedSuites() throws Exception { final TestSuites suites = parser.parse(new File("src/test/resources/" + PhpTestUtils.PHPUNIT_REPORT_DIR + "phpunit-junit-report.xml")); List<TestFileReport> reportsPerFile = suites.arrangeSuitesIntoTestFileReports(); assertThat(reportsPerFile.size()).isEqualTo(8); assertThat(reportsPerFile.get(5).getTests()).isEqualTo(3); assertThat(logTester.logs()).doesNotContain("Test cases must always be descendants of a file-based suite, skipping : testCanBeUsedAsString with data set #0 in App3Test::testCanBeUsedAsString"); }
@Test public void shouldWarnWhenFileAttributeDoesNotExist() throws Exception { final TestSuites suites = parser.parse(new File("src/test/resources/" + PhpTestUtils.PHPUNIT_REPORT_DIR + "phpunit-no-file.xml")); assertThat(suites.arrangeSuitesIntoTestFileReports().size()).isEqualTo(0); assertThat(logTester.logs()).contains("Test cases must always be descendants of a file-based suite, skipping : HelloWorldTest.testFoo2 in HelloWorldTest"); }