| 5752 | } |
| 5753 | |
| 5754 | void JsonUnitTestResultPrinter::PrintJsonTestList( |
| 5755 | std::ostream* stream, const std::vector<TestSuite*>& test_suites) { |
| 5756 | const std::string kTestsuites = "testsuites"; |
| 5757 | const std::string kIndent = Indent(2); |
| 5758 | *stream << "{\n"; |
| 5759 | int total_tests = 0; |
| 5760 | for (auto test_suite : test_suites) { |
| 5761 | total_tests += test_suite->total_test_count(); |
| 5762 | } |
| 5763 | OutputJsonKey(stream, kTestsuites, "tests", total_tests, kIndent); |
| 5764 | |
| 5765 | OutputJsonKey(stream, kTestsuites, "name", "AllTests", kIndent); |
| 5766 | *stream << kIndent << "\"" << kTestsuites << "\": [\n"; |
| 5767 | |
| 5768 | for (size_t i = 0; i < test_suites.size(); ++i) { |
| 5769 | if (i != 0) { |
| 5770 | *stream << ",\n"; |
| 5771 | } |
| 5772 | PrintJsonTestSuite(stream, *test_suites[i]); |
| 5773 | } |
| 5774 | |
| 5775 | *stream << "\n" |
| 5776 | << kIndent << "]\n" |
| 5777 | << "}\n"; |
| 5778 | } |
| 5779 | // Produces a string representing the test properties in a result as |
| 5780 | // a JSON dictionary. |
| 5781 | std::string JsonUnitTestResultPrinter::TestPropertiesAsJson( |
no test coverage detected