Prints a JSON summary of unit_test to output stream out.
| 5707 | |
| 5708 | // Prints a JSON summary of unit_test to output stream out. |
| 5709 | void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream, |
| 5710 | const UnitTest& unit_test) { |
| 5711 | const std::string kTestsuites = "testsuites"; |
| 5712 | const std::string kIndent = Indent(2); |
| 5713 | *stream << "{\n"; |
| 5714 | |
| 5715 | OutputJsonKey(stream, kTestsuites, "tests", unit_test.reportable_test_count(), |
| 5716 | kIndent); |
| 5717 | OutputJsonKey(stream, kTestsuites, "failures", unit_test.failed_test_count(), |
| 5718 | kIndent); |
| 5719 | OutputJsonKey(stream, kTestsuites, "disabled", |
| 5720 | unit_test.reportable_disabled_test_count(), kIndent); |
| 5721 | OutputJsonKey(stream, kTestsuites, "errors", 0, kIndent); |
| 5722 | if (GTEST_FLAG(shuffle)) { |
| 5723 | OutputJsonKey(stream, kTestsuites, "random_seed", unit_test.random_seed(), |
| 5724 | kIndent); |
| 5725 | } |
| 5726 | OutputJsonKey(stream, kTestsuites, "timestamp", |
| 5727 | FormatEpochTimeInMillisAsRFC3339(unit_test.start_timestamp()), |
| 5728 | kIndent); |
| 5729 | OutputJsonKey(stream, kTestsuites, "time", |
| 5730 | FormatTimeInMillisAsDuration(unit_test.elapsed_time()), kIndent, |
| 5731 | false); |
| 5732 | |
| 5733 | *stream << TestPropertiesAsJson(unit_test.ad_hoc_test_result(), kIndent) |
| 5734 | << ",\n"; |
| 5735 | |
| 5736 | OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent); |
| 5737 | *stream << kIndent << "\"" << kTestsuites << "\": [\n"; |
| 5738 | |
| 5739 | bool comma = false; |
| 5740 | for (int i = 0; i < unit_test.total_test_suite_count(); ++i) { |
| 5741 | if (unit_test.GetTestSuite(i)->reportable_test_count() > 0) { |
| 5742 | if (comma) { |
| 5743 | *stream << ",\n"; |
| 5744 | } else { |
| 5745 | comma = true; |
| 5746 | } |
| 5747 | PrintJsonTestSuite(stream, *unit_test.GetTestSuite(i)); |
| 5748 | } |
| 5749 | } |
| 5750 | |
| 5751 | *stream << "\n" << kIndent << "]\n" << "}\n"; |
| 5752 | } |
| 5753 | |
| 5754 | void JsonUnitTestResultPrinter::PrintJsonTestList( |
| 5755 | std::ostream* stream, const std::vector<TestSuite*>& test_suites) { |
nothing calls this directly
no test coverage detected