#include <test_record_event_handler.h>
Public Member Functions | |
TestRecordEventHandler (int64_t seconds_since_epoch) | |
void | TestCaseEnd (const TestCase &test_case, TestResult result) override |
void | RunAllTestsEnd (const RunTestsSummary &summary) override |
void | TestCaseExpect (const TestCase &test_case, const TestExpectation &expectation) override |
std::string | GetTestRecordJsonString (size_t max_json_buffer_size, bool failing_results_only=false) |
void | RunAllTestsStart () override |
Called before all tests are run. | |
void | TestProgramStart (const ProgramSummary &) override |
Called before any test activity starts. | |
void | EnvironmentsSetUpEnd () override |
Called after environment setup for each iteration of tests ends. | |
void | TestSuiteStart (const TestSuite &) override |
Called before the test suite starts. | |
void | TestSuiteEnd (const TestSuite &) override |
Called after the test suite ends. | |
void | EnvironmentsTearDownEnd () override |
Called after environment teardown for each iteration of tests ends. | |
void | TestProgramEnd (const ProgramSummary &) override |
Called after all test activities have ended. | |
void | TestCaseStart (const TestCase &) override |
Called when a new test case is started. | |
void | TestCaseDisabled (const TestCase &) override |
Called when a disabled test case is encountered. | |
virtual void | TestProgramStart (const ProgramSummary &program_summary)=0 |
Called before any test activity starts. | |
virtual void | EnvironmentsSetUpEnd ()=0 |
Called after environment setup for each iteration of tests ends. | |
virtual void | TestSuiteStart (const TestSuite &test_suite)=0 |
Called before the test suite starts. | |
virtual void | TestSuiteEnd (const TestSuite &test_suite)=0 |
Called after the test suite ends. | |
virtual void | EnvironmentsTearDownEnd ()=0 |
Called after environment teardown for each iteration of tests ends. | |
virtual void | TestProgramEnd (const ProgramSummary &program_summary)=0 |
Called after all test activities have ended. | |
virtual void | RunAllTestsStart ()=0 |
Called before all tests are run. | |
virtual void | RunAllTestsEnd (const RunTestsSummary &run_tests_summary)=0 |
Called after all tests are run. | |
virtual void | TestCaseStart (const TestCase &test_case)=0 |
Called when a new test case is started. | |
virtual void | TestCaseEnd (const TestCase &test_case, TestResult result)=0 |
virtual void | TestCaseDisabled (const TestCase &) |
Called when a disabled test case is encountered. | |
virtual void | TestCaseExpect (const TestCase &test_case, const TestExpectation &expectation)=0 |
Predefined event handler implementation that outputs a test record (or summary) in Chromium JSON Test Results Format. To use it, register the event handler, call the RUN_ALL_TESTS
macro, then extract the test record json as a string using the GetTestRecordJsonString
method. If you only want to extract the failing tests, set the failing_results_only
parameter to true. See pw::unit_test::EventHandler
for explanations of emitted events.
new
/delete
/std::string
) to generate the test record json.
|
inline |
Constructor for the event handler. Have to seconds_since_epoch since calling std::time(nullptr) in pigweed is not supported.
[in] | seconds_since_epoch | Seconds since epoch. Used in the test record as the seconds since epoch for the start of the test run. |
|
inlineoverridevirtual |
Called after environment setup for each iteration of tests ends.
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called after environment teardown for each iteration of tests ends.
Implements pw::unit_test::EventHandler.
|
inline |
Converts the test record trie into a json string and returns it.
[in] | max_json_buffer_size | The max size (in bytes) of the buffer to allocate for the json string. |
[in] | failing_results_only | If true, the outputted test record will only contain the failing tests. |
|
inlineoverridevirtual |
Called after all tests are run. Save the run tests summary for later use.
[in] | summary | A test run summary. Contains counts of each test result type. |
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called before all tests are run.
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called when a disabled test case is encountered.
Reimplemented from pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called when a test case completes. Record the test case result in the test record trie.
[in] | test_case | Test case that ended. |
[in] | result | Result of the test case. |
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called after each expect/assert statement within a test case with the result of the expectation.
We usually expect all tests to PASS. However, if the GTEST_SKIP macro is used, the test is expected to be skipped and the expectation expression is replaced with "(test skipped)"
[in] | test_case | Test case that the expect statement lies in. |
[in] | expectation | Current expectation being checked for the test case. |
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called when a new test case is started.
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called after all test activities have ended.
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called before any test activity starts.
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called after the test suite ends.
Implements pw::unit_test::EventHandler.
|
inlineoverridevirtual |
Called before the test suite starts.
Implements pw::unit_test::EventHandler.