private void writeTestSuiteStart(String test_suite_name) throws IllegalArgumentException, IllegalStateException, IOException { main_serial.startTag(null, "testsuite"); if (StringUtil.isNotEmpty(test_suite_name)) main_serial.attribute(null, "name", test_suite_name); }
// @see PHPUnit/Util/Log/JUnit.php#startTestSuite public void writeResult(boolean store_output, PhpUnitTestResult result) throws IllegalArgumentException, IllegalStateException, IOException { if (closed) throw new IllegalStateException("can not write to closed PhpUnitResultWriter. it is closed."); if (result.ini != null && (this.ini == null || !this.ini.equals(result.ini))) this.ini = result.ini; test_count++; final String test_name = result.getName(); status_list_map.get(result.status).write(test_name, result); if ((store_output || (result.status == EPhpUnitTestStatus.FAILURE || result.status == EPhpUnitTestStatus.ERROR || result.status == EPhpUnitTestStatus.CRASH)) && StringUtil.isNotEmpty(result.output)) { // store crash output too: for exit code and status output_by_name.put(test_name, result.output); } // write file header String test_suite_name = result.test_case.getPhpUnitDist() != null && result.test_case.getPhpUnitDist().getPath() != null ? result.test_case.getPhpUnitDist().getPath().getPath() : null; if (is_first_result) { main_serial.startDocument("utf-8", null); main_serial.setPrefix("pftt", "pftt"); main_serial.startTag(null, "testsuites"); writeTestSuiteStart(test_suite_name); is_first_result = false; } else if (test_suite_name != null && last_test_suite_name != null && !test_suite_name.equals(last_test_suite_name)) { writeTestSuiteEnd(); writeTestSuiteStart(test_suite_name); } last_test_suite_name = test_suite_name; // // write result itself result.serial(main_serial); // if ((result.code_coverage != null || result.extra != null) && PhpUnitTestResult.shouldStoreAllInfo(result.status)) { // store this data in a separate file File f = new File( dir, result .getName() .replace("::", "_") .replace("(", "_") .replace(")", "") .replace(".php", "") + ".xml"); f.getParentFile().mkdirs(); // ensure directory exists FileWriter fw = new FileWriter(f); extra_serial.setOutput(fw); extra_serial.startDocument("utf-8", Boolean.TRUE); extra_serial.startTag("pftt", "phpUnitTestResult"); if (result.extra != null) result.extra.serial(extra_serial); if (result.code_coverage != null) result.code_coverage.serial(extra_serial); extra_serial.endTag("pftt", "phpUnitTestResult"); extra_serial.endDocument(); extra_serial.flush(); fw.close(); } // // store name, status and run-time in CSV format all_csv_pw.print("'"); all_csv_pw.print(test_name); all_csv_pw.print("','"); all_csv_pw.print(result.status); all_csv_pw.print("',"); all_csv_pw.print(result.run_time_micros); all_csv_pw.println(); } // end public void writeResult