test_suite.cpp
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 // This file is part of FZIs ic_workspace.
00005 //
00006 // This program is free software licensed under the LGPL
00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
00008 // You can find a copy of this license in LICENSE folder in the top
00009 // directory of the source code.
00010 //
00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
00012 //
00013 // -- END LICENSE BLOCK ------------------------------------------------
00014 
00015 //----------------------------------------------------------------------
00022 //----------------------------------------------------------------------
00023 
00024 #include <cppunit/TextOutputter.h>
00025 #include <cppunit/CompilerOutputter.h>
00026 #include <cppunit/XmlOutputter.h>
00027 #include <cppunit/TestResult.h>
00028 #include <cppunit/TestResultCollector.h>
00029 #include <cppunit/TestRunner.h>
00030 #include <cppunit/extensions/TestFactoryRegistry.h>
00031 
00032 #include <icl_core/os_lxrt.h>
00033 #include <icl_core_logging/Logging.h>
00034 
00035 #include "icl_core_testsuite/TestListener.h"
00036 #include "icl_core_testsuite/test_suite.h"
00037 
00038 namespace icl_core {
00039 
00040 int runCppunitTestSuite(TestResultOutputType outputType)
00041 {
00042   icl_core::os::lxrtStartup();
00043   icl_core::logging::initialize();
00044 
00045   // Informiert Test-Listener ueber Testresultate
00046   CPPUNIT_NS::TestResult testresult;
00047 
00048   // Listener zum Sammeln der Testergebnisse registrieren
00049   CPPUNIT_NS::TestResultCollector collectedresults;
00050   testresult.addListener(&collectedresults);
00051 
00052   // Test-Suite ueber die Registry im Test-Runner einfuegen
00053   CPPUNIT_NS::TestRunner testrunner;
00054   testrunner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
00055 
00056   // Resultate ausgeben
00057   switch (outputType)
00058   {
00059     case eTROT_Text:
00060     {
00061       icl_core::TestListener progress;
00062       testresult.addListener(&progress);
00063 
00064       testrunner.run(testresult);
00065 
00066       CPPUNIT_NS::TextOutputter textoutputter(&collectedresults, std::cerr);
00067       textoutputter.write();
00068       break;
00069     }
00070     case eTROT_Compiler:
00071     {
00072       icl_core::TestListener progress;
00073       testresult.addListener(&progress);
00074 
00075       testrunner.run(testresult);
00076 
00077       CPPUNIT_NS::CompilerOutputter compileroutputter(&collectedresults, std::cerr);
00078       compileroutputter.write();
00079       break;
00080     }
00081     case eTROT_Xml:
00082     {
00083       testrunner.run(testresult);
00084 
00085       CPPUNIT_NS::XmlOutputter xmloutputter(&collectedresults, std::cerr, "UTF-8");
00086       xmloutputter.write();
00087       break;
00088     }
00089   }
00090 
00091   icl_core::logging::shutdown();
00092   icl_core::os::lxrtShutdown();
00093 
00094   // Rueckmeldung, ob Tests erfolgreich waren
00095   return collectedresults.wasSuccessful() ? 0 : 1;
00096 }
00097 
00099 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
00100 
00101 int RunCppunitTestSuite(TestResultOutputType outputType)
00102 {
00103   return runCppunitTestSuite(outputType);
00104 }
00105 
00106 #endif
00107 
00108 
00109 }


fzi_icl_core
Author(s):
autogenerated on Thu Jun 6 2019 20:22:24