Prints an JSON representation of a TestSuite object
| 5668 | |
| 5669 | // Prints an JSON representation of a TestSuite object |
| 5670 | void JsonUnitTestResultPrinter::PrintJsonTestSuite( |
| 5671 | std::ostream* stream, const TestSuite& test_suite) { |
| 5672 | const std::string kTestsuite = "testsuite"; |
| 5673 | const std::string kIndent = Indent(6); |
| 5674 | |
| 5675 | *stream << Indent(4) << "{\n"; |
| 5676 | OutputJsonKey(stream, kTestsuite, "name", test_suite.name(), kIndent); |
| 5677 | OutputJsonKey(stream, kTestsuite, "tests", test_suite.reportable_test_count(), |
| 5678 | kIndent); |
| 5679 | if (!GTEST_FLAG(list_tests)) { |
| 5680 | OutputJsonKey(stream, kTestsuite, "failures", |
| 5681 | test_suite.failed_test_count(), kIndent); |
| 5682 | OutputJsonKey(stream, kTestsuite, "disabled", |
| 5683 | test_suite.reportable_disabled_test_count(), kIndent); |
| 5684 | OutputJsonKey(stream, kTestsuite, "errors", 0, kIndent); |
| 5685 | OutputJsonKey(stream, kTestsuite, "time", |
| 5686 | FormatTimeInMillisAsDuration(test_suite.elapsed_time()), |
| 5687 | kIndent, false); |
| 5688 | *stream << TestPropertiesAsJson(test_suite.ad_hoc_test_result(), kIndent) |
| 5689 | << ",\n"; |
| 5690 | } |
| 5691 | |
| 5692 | *stream << kIndent << "\"" << kTestsuite << "\": [\n"; |
| 5693 | |
| 5694 | bool comma = false; |
| 5695 | for (int i = 0; i < test_suite.total_test_count(); ++i) { |
| 5696 | if (test_suite.GetTestInfo(i)->is_reportable()) { |
| 5697 | if (comma) { |
| 5698 | *stream << ",\n"; |
| 5699 | } else { |
| 5700 | comma = true; |
| 5701 | } |
| 5702 | OutputJsonTestInfo(stream, test_suite.name(), *test_suite.GetTestInfo(i)); |
| 5703 | } |
| 5704 | } |
| 5705 | *stream << "\n" << kIndent << "]\n" << Indent(4) << "}"; |
| 5706 | } |
| 5707 | |
| 5708 | // Prints a JSON summary of unit_test to output stream out. |
| 5709 | void JsonUnitTestResultPrinter::PrintJsonUnitTest(std::ostream* stream, |
nothing calls this directly
no test coverage detected