MCPcopy Create free account
hub / github.com/awslabs/aws-lambda-cpp / PrintJsonUnitTest

Method PrintJsonUnitTest

tests/gtest/gtest-all.cc:5709–5752  ·  view source on GitHub ↗

Prints a JSON summary of unit_test to output stream out.

Source from the content-addressed store, hash-verified

5707
5708// Prints a JSON summary of unit_test to output stream out.
5709void 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
5754void JsonUnitTestResultPrinter::PrintJsonTestList(
5755 std::ostream* stream, const std::vector<TestSuite*>& test_suites) {

Callers

nothing calls this directly

Calls 11

IndentFunction · 0.85
reportable_test_countMethod · 0.80
failed_test_countMethod · 0.80
random_seedMethod · 0.80
start_timestampMethod · 0.80
elapsed_timeMethod · 0.80
GetTestSuiteMethod · 0.80

Tested by

no test coverage detected