unittest/sam/main.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 // TerraLib
21 #include <terralib/common.h>
22 
23 // cppUnit
24 #include <cppunit/BriefTestProgressListener.h>
25 #include <cppunit/CompilerOutputter.h>
26 #include <cppunit/XmlOutputter.h>
27 #include <cppunit/extensions/HelperMacros.h>
28 #include <cppunit/extensions/TestFactoryRegistry.h>
29 #include <cppunit/TestResult.h>
30 #include <cppunit/TestResultCollector.h>
31 #include <cppunit/TestRunner.h>
32 
33 // Unit-Test TerraLib includes by platform
34 #include "../Config.h"
35 
36 int main(int /*argc*/, char** /*argv*/)
37 {
38 // initialize Terralib platform
40 // it creates the event manager and test controller
41  CPPUNIT_NS::TestResult controller;
42 
43 // it adds a listener that colllects test result
44  CPPUNIT_NS::TestResultCollector result;
45 
46  controller.addListener(&result);
47 
48 // it adds a listener that print dots as test run.
49  CPPUNIT_NS::BriefTestProgressListener progress;
50 
51  controller.addListener(&progress);
52 
53 // it adds the top suite to the test runner
54  CppUnit::Test* suite = CppUnit::TestFactoryRegistry::getRegistry().makeTest();
55 
56  CPPUNIT_NS::TestRunner runner;
57 
58  runner.addTest(suite);
59 
60  runner.run(controller);
61 
62  CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
63 
64  outputter.write();
65 
66 // Printing testResult in XML file
67  // The testResult_*.xml files will be saved at TERRALIB_REPORT_DIR directory.
68  // The styleSheet 'report.xsl' should be at this directory (found originally at <third-party-lib>\cppunit-1.12.1\contrib\xml-xsl).
69  // The "data.zip" (downloaded) containing the data used in unit tests should be at TERRALIB_DATA_DIR
70  CPPUNIT_NS::OFileStream file2( TERRALIB_REPORT_DIR"/testsResult_sam_xml.xml" );
71  CPPUNIT_NS::XmlOutputter xml( &result, file2 );
72  xml.setStyleSheet( "report.xsl" ); //it is found at c:\....\cppunit-1.12.1\contrib\xml-xsl
73  xml.write();
74  file2.close();
75 
76  //Giving time to see CPPUNIT_ASSERT_MESSAGE in a DOS window
77  //CPPUNIT_NS::stdCOut() << "\n Press keyboard to exit \n";
78  //while(! getchar());
79 
80  bool resultStatus = result.wasSuccessful();
81 
83 
84  return resultStatus ? EXIT_SUCCESS : EXIT_FAILURE;
85 }
86 
void finalize()
It finalizes the TerraLib Platform.
static TerraLib & getInstance()
It returns a reference to the singleton instance.
void initialize()
It initializes the TerraLib Platform.
This file contains include headers for the TerraLib Common Runtime module.
int main(int, char **)