Pigweed
 
Loading...
Searching...
No Matches
pw::unit_test::EventHandler Class Referenceabstract

#include <event_handler.h>

Inheritance diagram for pw::unit_test::EventHandler:
pw::unit_test::GoogleTestStyleEventHandler pw::unit_test::LoggingEventHandler pw::unit_test::MultiEventHandler< kNumHandlers > pw::unit_test::TestRecordEventHandler pw::unit_test::PrintfEventHandler pw::unit_test::SimplePrintingEventHandler

Public Member Functions

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
 

Detailed Description

Collects and processes the results of a unit test run. Its interface is called by the unit test framework as tests are executed and various test events occur.

A program wanting to process test events must define a class implementing the pw::unit_test::EventHandler interface and register it with the framework. When RUN_ALL_TESTS() is called, pw_unit_test notifies the handler of various events which occur in the test process. For example, consider a file containing the following test definitions:

TEST(MyTestSuite, MyFirstCase) {
EXPECT_TRUE(true);
}
TEST(MyTestSuite, MySecondCase) {
EXPECT_TRUE(false);
}

There's one test suite consisting of two test cases. When pw_unit_test starts running the first test case (MyFirstCase), it dispatches a TestCaseStart event to the event handler. It then runs the body of the test, sequentially checking each expectation within. After each expectation, a TestCaseExpect event is sent to the event handler with the expectation's result. In this case, there's only one, which passes successfully. Finally, after the test is finished, a TestCaseEnd event is dispatched with the overall result of the test case. pw_unit_test then runs MySecondCase in the same way.

Member Function Documentation

◆ EnvironmentsSetUpEnd()

virtual void pw::unit_test::EventHandler::EnvironmentsSetUpEnd ( )
pure virtual

◆ EnvironmentsTearDownEnd()

virtual void pw::unit_test::EventHandler::EnvironmentsTearDownEnd ( )
pure virtual

◆ RunAllTestsEnd()

virtual void pw::unit_test::EventHandler::RunAllTestsEnd ( const RunTestsSummary run_tests_summary)
pure virtual

◆ RunAllTestsStart()

virtual void pw::unit_test::EventHandler::RunAllTestsStart ( )
pure virtual

◆ TestCaseDisabled()

virtual void pw::unit_test::EventHandler::TestCaseDisabled ( const TestCase )
inlinevirtual

◆ TestCaseEnd()

virtual void pw::unit_test::EventHandler::TestCaseEnd ( const TestCase test_case,
TestResult  result 
)
pure virtual

Called when a test case completes. The overall result of the test case is provided.

Implemented in pw::unit_test::GoogleTestStyleEventHandler, pw::unit_test::LoggingEventHandler, pw::unit_test::MultiEventHandler< kNumHandlers >, and pw::unit_test::TestRecordEventHandler.

◆ TestCaseExpect()

virtual void pw::unit_test::EventHandler::TestCaseExpect ( const TestCase test_case,
const TestExpectation expectation 
)
pure virtual

Called after each expect or assert statement within a test case with the result.

Implemented in pw::unit_test::GoogleTestStyleEventHandler, pw::unit_test::LoggingEventHandler, pw::unit_test::MultiEventHandler< kNumHandlers >, and pw::unit_test::TestRecordEventHandler.

◆ TestCaseStart()

virtual void pw::unit_test::EventHandler::TestCaseStart ( const TestCase test_case)
pure virtual

◆ TestProgramEnd()

virtual void pw::unit_test::EventHandler::TestProgramEnd ( const ProgramSummary program_summary)
pure virtual

◆ TestProgramStart()

virtual void pw::unit_test::EventHandler::TestProgramStart ( const ProgramSummary program_summary)
pure virtual

◆ TestSuiteEnd()

virtual void pw::unit_test::EventHandler::TestSuiteEnd ( const TestSuite test_suite)
pure virtual

◆ TestSuiteStart()

virtual void pw::unit_test::EventHandler::TestSuiteStart ( const TestSuite test_suite)
pure virtual

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