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

Class JsonUnitTestResultPrinter

tests/gtest/gtest-all.cc:5427–5478  ·  view source on GitHub ↗

This class generates an JSON output file.

Source from the content-addressed store, hash-verified

5425
5426// This class generates an JSON output file.
5427class JsonUnitTestResultPrinter : public EmptyTestEventListener {
5428 public:
5429 explicit JsonUnitTestResultPrinter(const char* output_file);
5430
5431 void OnTestIterationEnd(const UnitTest& unit_test, int iteration) override;
5432
5433 // Prints an JSON summary of all unit tests.
5434 static void PrintJsonTestList(::std::ostream* stream,
5435 const std::vector<TestSuite*>& test_suites);
5436
5437 private:
5438 // Returns an JSON-escaped copy of the input string str.
5439 static std::string EscapeJson(const std::string& str);
5440
5441 //// Verifies that the given attribute belongs to the given element and
5442 //// streams the attribute as JSON.
5443 static void OutputJsonKey(std::ostream* stream,
5444 const std::string& element_name,
5445 const std::string& name,
5446 const std::string& value,
5447 const std::string& indent,
5448 bool comma = true);
5449 static void OutputJsonKey(std::ostream* stream,
5450 const std::string& element_name,
5451 const std::string& name,
5452 int value,
5453 const std::string& indent,
5454 bool comma = true);
5455
5456 // Streams a JSON representation of a TestInfo object.
5457 static void OutputJsonTestInfo(::std::ostream* stream,
5458 const char* test_suite_name,
5459 const TestInfo& test_info);
5460
5461 // Prints a JSON representation of a TestSuite object
5462 static void PrintJsonTestSuite(::std::ostream* stream,
5463 const TestSuite& test_suite);
5464
5465 // Prints a JSON summary of unit_test to output stream out.
5466 static void PrintJsonUnitTest(::std::ostream* stream,
5467 const UnitTest& unit_test);
5468
5469 // Produces a string representing the test properties in a result as
5470 // a JSON dictionary.
5471 static std::string TestPropertiesAsJson(const TestResult& result,
5472 const std::string& indent);
5473
5474 // The output file.
5475 const std::string output_file_;
5476
5477 GTEST_DISALLOW_COPY_AND_ASSIGN_(JsonUnitTestResultPrinter);
5478};
5479
5480// Creates a new JsonUnitTestResultPrinter.
5481JsonUnitTestResultPrinter::JsonUnitTestResultPrinter(const char* output_file)

Callers 1

Calls

no outgoing calls

Tested by 1