]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
custom listener for automatic tests
authorasl <asl@opencascade.com>
Thu, 15 Oct 2015 05:37:37 +0000 (08:37 +0300)
committerasl <asl@opencascade.com>
Thu, 15 Oct 2015 05:37:37 +0000 (08:37 +0300)
src/HYDRO_tests/CMakeLists.txt
src/HYDRO_tests/TestLib_Listener.cxx [new file with mode: 0644]
src/HYDRO_tests/TestLib_Listener.h [new file with mode: 0644]
src/HYDRO_tests/test_HYDROData_Main.cxx

index c7179cdd5bb7a23e5b63f202c7bd372667b73473..08731d0fa169e5ce7e19f774e2a0597eb5858be9 100644 (file)
@@ -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 (file)
index 0000000..089d839
--- /dev/null
@@ -0,0 +1,77 @@
+
+/**
+  @file
+  \brief Implementation of the custom listener printing the time of test execution
+*/
+
+#include <TestLib_Listener.h>
+#include <cppunit/Test.h>
+#include <iostream>
+
+/**
+  \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 (file)
index 0000000..0270d20
--- /dev/null
@@ -0,0 +1,31 @@
+
+/**
+  @file
+  \brief Declaration of the custom listener printing the time of test execution
+*/
+
+#pragma once
+
+#include <cppunit/TestListener.h>
+
+/**
+  \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& );
+};
+
index 360841ac26d01438d2a17cf446e405bf93f6b3ec..febcf83b1adcdf581f2ae835386bcb911339ea74 100644 (file)
@@ -20,9 +20,9 @@
 #include <cppunit/CompilerOutputter.h>
 #include <cppunit/TestResult.h>
 #include <cppunit/TestResultCollector.h>
-#include <cppunit/TextTestProgressListener.h>
 #include <stdexcept>
 #include <TestViewer.h>
+#include <TestLib_Listener.h>
 #include <TestLib_Runner.h>
 #include <OCCViewer_ViewWindow.h>
 #include <SUIT_Session.h>
@@ -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 =