test_suite.cpp
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 
24 #include <cppunit/TextOutputter.h>
25 #include <cppunit/CompilerOutputter.h>
26 #include <cppunit/XmlOutputter.h>
27 #include <cppunit/TestResult.h>
28 #include <cppunit/TestResultCollector.h>
29 #include <cppunit/TestRunner.h>
30 #include <cppunit/extensions/TestFactoryRegistry.h>
31 
32 #include <icl_core/os_lxrt.h>
34 
37 
38 namespace icl_core {
39 
41 {
44 
45  // Informiert Test-Listener ueber Testresultate
46  CPPUNIT_NS::TestResult testresult;
47 
48  // Listener zum Sammeln der Testergebnisse registrieren
49  CPPUNIT_NS::TestResultCollector collectedresults;
50  testresult.addListener(&collectedresults);
51 
52  // Test-Suite ueber die Registry im Test-Runner einfuegen
53  CPPUNIT_NS::TestRunner testrunner;
54  testrunner.addTest(CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest());
55 
56  // Resultate ausgeben
57  switch (outputType)
58  {
59  case eTROT_Text:
60  {
61  icl_core::TestListener progress;
62  testresult.addListener(&progress);
63 
64  testrunner.run(testresult);
65 
66  CPPUNIT_NS::TextOutputter textoutputter(&collectedresults, std::cerr);
67  textoutputter.write();
68  break;
69  }
70  case eTROT_Compiler:
71  {
72  icl_core::TestListener progress;
73  testresult.addListener(&progress);
74 
75  testrunner.run(testresult);
76 
77  CPPUNIT_NS::CompilerOutputter compileroutputter(&collectedresults, std::cerr);
78  compileroutputter.write();
79  break;
80  }
81  case eTROT_Xml:
82  {
83  testrunner.run(testresult);
84 
85  CPPUNIT_NS::XmlOutputter xmloutputter(&collectedresults, std::cerr, "UTF-8");
86  xmloutputter.write();
87  break;
88  }
89  }
90 
93 
94  // Rueckmeldung, ob Tests erfolgreich waren
95  return collectedresults.wasSuccessful() ? 0 : 1;
96 }
97 
99 #ifdef _IC_BUILDER_DEPRECATED_STYLE_
100 
101 int RunCppunitTestSuite(TestResultOutputType outputType)
102 {
103  return runCppunitTestSuite(outputType);
104 }
105 
106 #endif
107 
109 }
void lxrtShutdown()
Definition: os_lxrt.cpp:74
bool initialize(int &argc, char *argv[], bool remove_read_arguments)
void lxrtStartup()
Definition: os_lxrt.cpp:61
int runCppunitTestSuite(TestResultOutputType outputType)
Definition: test_suite.cpp:40
Defines logging macros.
TestResultOutputType
Definition: test_suite.h:34
Contains icl_core::TestListener.
Contains global LXRT functions.


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58