Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::internal::JsonUnitTestResultPrinter Class Reference
Inheritance diagram for testing::internal::JsonUnitTestResultPrinter:
Collaboration diagram for testing::internal::JsonUnitTestResultPrinter:

Public Member Functions

 JsonUnitTestResultPrinter (const char *output_file)
 
virtual void OnTestIterationEnd (const UnitTest &unit_test, int iteration)
 
- Public Member Functions inherited from testing::EmptyTestEventListener
virtual void OnTestProgramStart (const UnitTest &)
 
virtual void OnTestIterationStart (const UnitTest &, int)
 
virtual void OnEnvironmentsSetUpStart (const UnitTest &)
 
virtual void OnEnvironmentsSetUpEnd (const UnitTest &)
 
virtual void OnTestCaseStart (const TestCase &)
 
virtual void OnTestStart (const TestInfo &)
 
virtual void OnTestPartResult (const TestPartResult &)
 
virtual void OnTestEnd (const TestInfo &)
 
virtual void OnTestCaseEnd (const TestCase &)
 
virtual void OnEnvironmentsTearDownStart (const UnitTest &)
 
virtual void OnEnvironmentsTearDownEnd (const UnitTest &)
 
virtual void OnTestProgramEnd (const UnitTest &)
 
- Public Member Functions inherited from testing::TestEventListener
virtual ~TestEventListener ()
 

Detailed Description

Definition at line 3827 of file gtest.cc.

Constructor & Destructor Documentation

◆ JsonUnitTestResultPrinter()

testing::internal::JsonUnitTestResultPrinter::JsonUnitTestResultPrinter ( const char * output_file)
explicit

Definition at line 3877 of file gtest.cc.

3878 : output_file_(output_file) {
3879 if (output_file_.empty()) {
3880 GTEST_LOG_(FATAL) << "JSON output file may not be null";
3881 }
3882}
#define GTEST_LOG_(severity)

Member Function Documentation

◆ OnTestIterationEnd()

void testing::internal::JsonUnitTestResultPrinter::OnTestIterationEnd ( const UnitTest & unit_test,
int iteration )
virtual

Reimplemented from testing::EmptyTestEventListener.

Definition at line 3884 of file gtest.cc.

3885 {
3886 FILE* jsonout = NULL;
3887 FilePath output_file(output_file_);
3888 FilePath output_dir(output_file.RemoveFileName());
3889
3890 if (output_dir.CreateDirectoriesRecursively()) {
3891 jsonout = posix::FOpen(output_file_.c_str(), "w");
3892 }
3893 if (jsonout == NULL) {
3894 // TODO(phosek): report the reason of the failure.
3895 //
3896 // We don't do it for now as:
3897 //
3898 // 1. There is no urgent need for it.
3899 // 2. It's a bit involved to make the errno variable thread-safe on
3900 // all three operating systems (Linux, Windows, and Mac OS).
3901 // 3. To interpret the meaning of errno in a thread-safe way,
3902 // we need the strerror_r() function, which is not available on
3903 // Windows.
3904 GTEST_LOG_(FATAL) << "Unable to open file \""
3905 << output_file_ << "\"";
3906 }
3907 std::stringstream stream;
3908 PrintJsonUnitTest(&stream, unit_test);
3909 fprintf(jsonout, "%s", StringStreamToString(&stream).c_str());
3910 fclose(jsonout);
3911}
FILE * FOpen(const char *path, const char *mode)
GTEST_API_ std::string StringStreamToString(::std::stringstream *stream)
Definition gtest.cc:1997
Here is the call graph for this function:

The documentation for this class was generated from the following file: