From: asl Date: Thu, 15 Oct 2015 05:37:37 +0000 (+0300) Subject: custom listener for automatic tests X-Git-Tag: v1.5~114 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=fbe7ca3126be3d0afca6806e7ede42201b97538f;p=modules%2Fhydro.git custom listener for automatic tests --- diff --git a/src/HYDRO_tests/CMakeLists.txt b/src/HYDRO_tests/CMakeLists.txt index c7179cdd..08731d0f 100644 --- a/src/HYDRO_tests/CMakeLists.txt +++ b/src/HYDRO_tests/CMakeLists.txt @@ -15,6 +15,7 @@ set(PROJECT_HEADERS test_HYDROGUI_ListModel.h TestViewer.h + TestLib_Listener.h TestLib_Runner.h ) @@ -33,6 +34,7 @@ set(PROJECT_SOURCES test_HYDROGUI_ListModel.cxx TestViewer.cxx + TestLib_Listener.cxx TestLib_Runner.cxx ) diff --git a/src/HYDRO_tests/TestLib_Listener.cxx b/src/HYDRO_tests/TestLib_Listener.cxx new file mode 100644 index 00000000..089d8395 --- /dev/null +++ b/src/HYDRO_tests/TestLib_Listener.cxx @@ -0,0 +1,77 @@ + +/** + @file + \brief Implementation of the custom listener printing the time of test execution +*/ + +#include +#include +#include + +/** + \brief Constructor +*/ +TestLib_Listener::TestLib_Listener() +{ +} + +/** + \brief Destructor +*/ +TestLib_Listener::~TestLib_Listener() +{ +} + +/** + \brief Clear the internal state of the listener +*/ +void TestLib_Listener::Clear() +{ +} + +/** + Handler for test start + @param theTest the started tests +*/ +void TestLib_Listener::startTest( CppUnit::Test* theTest ) +{ + std::string aName; + if( theTest ) + aName = theTest->getName(); + + std::cout << aName << "..."; +} + +/** + Handler for test finish + @param theTest the finished tests +*/ +void TestLib_Listener::endTest( CppUnit::Test* theTest ) +{ + std::cout << std::endl; +} + +/** + Handler for test suite start + @param theTest the started test suite +*/ +void TestLib_Listener::startSuite( CppUnit::Test* theTest ) +{ +} + +/** + Handler for test suite finish + @param theTest the finished test suite +*/ +void TestLib_Listener::endSuite( CppUnit::Test* theTest ) +{ +} + +/** + Handler for test failure + @param theFailure the failure information +*/ +void TestLib_Listener::addFailure( const CppUnit::TestFailure& theFailure ) +{ +} + diff --git a/src/HYDRO_tests/TestLib_Listener.h b/src/HYDRO_tests/TestLib_Listener.h new file mode 100644 index 00000000..0270d208 --- /dev/null +++ b/src/HYDRO_tests/TestLib_Listener.h @@ -0,0 +1,31 @@ + +/** + @file + \brief Declaration of the custom listener printing the time of test execution +*/ + +#pragma once + +#include + +/** + \class TestLib_Listener + \brief Implementation of the custom listener printing the time of test execution +*/ +class TestLib_Listener : public CppUnit::TestListener +{ +public: + TestLib_Listener(); + virtual ~TestLib_Listener(); + + void Clear(); + + virtual void startTest( CppUnit::Test* ); + virtual void endTest( CppUnit::Test* ); + + virtual void startSuite( CppUnit::Test* ); + virtual void endSuite( CppUnit::Test* ); + + virtual void addFailure( const CppUnit::TestFailure& ); +}; + diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index 360841ac..febcf83b 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -20,9 +20,9 @@ #include #include #include -#include #include #include +#include #include #include #include @@ -51,7 +51,7 @@ int main( int argc, char* argv[] ) controller.addListener( &result ); // Add a listener that print dots as test run. - CppUnit::TextTestProgressListener progress; + TestLib_Listener progress; controller.addListener( &progress ); CppUnit::TestFactoryRegistry& registry =