MCPcopy Create free account
hub / github.com/catboost/catboost / SerializeToJson

Method SerializeToJson

library/cpp/testing/unittest/junit.cpp:391–440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

389}
390
391void TJUnitProcessor::SerializeToJson() {
392 TFileOutput out(ResultReportFileName);
393 NJsonWriter::TBuf json(NJsonWriter::HEM_UNSAFE, &out);
394 json.SetIndentSpaces(1);
395 json.BeginObject();
396 {
397 json.WriteKey("tests"sv).WriteInt(GetTestsCount());
398 json.WriteKey("failures"sv).WriteInt(GetFailuresCount());
399 json.WriteKey("testsuites"sv).BeginList();
400 for (const auto& [suiteName, suite] : Suites) {
401 json.BeginObject();
402 json.WriteKey("name"sv).WriteString(suiteName);
403 json.WriteKey("id"sv).WriteString(suiteName);
404 json.WriteKey("tests"sv).WriteInt(suite.GetTestsCount());
405 json.WriteKey("failures"sv).WriteInt(suite.GetFailuresCount());
406 json.WriteKey("time"sv).WriteDouble(suite.GetDurationSeconds());
407 json.WriteKey("testcases"sv).BeginList();
408 for (const auto& [testName, test] : suite.Cases) {
409 json.BeginObject();
410 json.WriteKey("classname"sv).WriteString(suiteName);
411 json.WriteKey("name"sv).WriteString(testName);
412 json.WriteKey("id"sv).WriteString(testName);
413 json.WriteKey("time"sv).WriteDouble(test.DurationSecods);
414 json.WriteKey("failures"sv).BeginList();
415 for (const auto& failure : test.Failures) {
416 json.BeginObject();
417 json.WriteKey("message"sv).WriteString(failure.Message);
418 json.WriteKey("type"sv).WriteString("ERROR"sv);
419 if (failure.BackTrace) {
420 json.WriteKey("backtrace"sv).WriteString(failure.BackTrace);
421 }
422 json.EndObject();
423 }
424 json.EndList();
425
426 if (!test.StdOut.empty()) {
427 json.WriteKey("system-out"sv).WriteString(test.StdOut);
428 }
429 if (!test.StdErr.empty()) {
430 json.WriteKey("system-err"sv).WriteString(test.StdErr);
431 }
432 json.EndObject();
433 }
434 json.EndList();
435 json.EndObject();
436 }
437 json.EndList();
438 }
439 json.EndObject();
440}
441
442class TXmlWriter {
443public:

Callers

nothing calls this directly

Calls 12

GetDurationSecondsMethod · 0.80
BeginObjectMethod · 0.45
WriteIntMethod · 0.45
WriteKeyMethod · 0.45
BeginListMethod · 0.45
WriteStringMethod · 0.45
GetTestsCountMethod · 0.45
GetFailuresCountMethod · 0.45
WriteDoubleMethod · 0.45
EndObjectMethod · 0.45
EndListMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected