source: ThirdParty/CodePatterns/TestRunnerClient.h@ 9a9f847

Action_Thermostats Add_AtomRandomPerturbation Add_RotateAroundBondAction Add_SelectAtomByNameAction Adding_Graph_to_ChangeBondActions Adding_MD_integration_tests Adding_StructOpt_integration_tests AutomationFragmentation_failures Candidate_v1.6.1 ChangeBugEmailaddress ChemicalSpaceEvaluator Docu_Python_wait EmpiricalPotential_contain_HomologyGraph_documentation Enhance_userguide Enhanced_StructuralOptimization Enhanced_StructuralOptimization_continued Example_ManyWaysToTranslateAtom Exclude_Hydrogens_annealWithBondGraph Fix_ChronosMutex Fix_StatusMsg Fix_StepWorldTime_single_argument Fix_Verbose_Codepatterns ForceAnnealing_oldresults ForceAnnealing_with_BondGraph ForceAnnealing_with_BondGraph_continued ForceAnnealing_with_BondGraph_continued_betteresults ForceAnnealing_with_BondGraph_contraction-expansion GeometryObjects Gui_displays_atomic_force_velocity IndependentFragmentGrids_IntegrationTest JobMarket_RobustOnKillsSegFaults JobMarket_StableWorkerPool PythonUI_with_named_parameters QtGui_reactivate_TimeChanged_changes Recreated_GuiChecks RotateToPrincipalAxisSystem_UndoRedo StoppableMakroAction TremoloParser_IncreasedPrecision TremoloParser_MultipleTimesteps
Last change on this file since 9a9f847 was 41e8e2, checked in by Frederik Heber <heber@…>, 8 years ago

Merge commit '084729c5923f0123e695fbe2548b393288c1f13d' as 'ThirdParty/CodePatterns'

  • Property mode set to 100644
File size: 4.1 KB
Line 
1/*******************************************************************************
2 * Copyright (c) 2008 Gerhard Leonhartsberger.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *******************************************************************************/
8
9#ifndef TESTRUNNERSERVER_H_
10#define TESTRUNNERSERVER_H_
11
12#ifdef CPPUNIT_MAIN
13
14#include "cppunit/TestListener.h"
15
16#include <vector>
17#include <string>
18
19/*!
20 * Class <code>TestRunnerClient</code> handles the network connection to the
21 * <code>CppUnitServer</code> and executes all registered CppUnit tests.
22 * <p>
23 * The meta data of the CppUnit tests and the test results are sent to the
24 * <code>CppUnitServer</code> for displaying.
25 * </p>
26 * <p>
27 * For debugging purposes class <code>TestRunnerClient</code> displays debug
28 * messages on <code>std.cerr</code>. The debug modus is activated by specifying
29 * <code>debug</code> command line option. The command line is parsed by method
30 * <code>Init()</code>.
31 * </p>
32 * <p>
33 * Note: This class is not intended to be subclassed by clients. This class is
34 * based on the original <code>RemoteTestRunner</code> class provided by
35 * <code>org.eclipse.cdt.cppunit</code>.
36 * </p>
37 *
38 * @author Gerhard Leonhartsberger
39 */
40class TestRunnerClient: public CppUnit::TestListener
41{
42private:
43 CppUnit::TestResult *fTestResult;
44 int fClientSocket;
45 char *fHost;
46 int fPort;
47 int fDebugMode;
48 int fKeepAlive;
49
50public:
51 TestRunnerClient();
52 virtual ~TestRunnerClient();
53
54 /*!
55 * Initializes the <code>TestRunnerClient</code>.
56 * <p>
57 * The given <code>args</code> are parsed. The syntax for the arguments is
58 * defined in EBNF as follows: <code>{-option=value}</code>
59 * </p>
60 *
61 * @param n The number of arguments.
62 * @param args The argument values. Valid options are:
63 * <li><code>-debug</code> When present the TestRunnerClient
64 * is run in debug modus and displays debug messages.</li>
65 * <li><code>-port=number</code> Defines the port where
66 * CppUnitServer is listening for client connections.</li>
67 */
68 void Init(int n,char *args[]);
69
70 /*!
71 * Runs the TestRunnerClient. A trial to connect to the CppUnitServer is done.
72 * The test results are sent to the CppUnitServer.
73 *
74 * @return The return value is <code>0</code> when the CppUnitServer was connected successfully
75 * otherwise the return value is <code>-1</code>.
76 */
77 int Run();
78
79 /*!
80 * Stops processing <code>CppUnit</code> from executing tests.
81 */
82 void Stop();
83
84 /*!
85 * Method defined in <code>CppUnit::TestListener</code>.
86 */
87 void startTest(CppUnit::Test *test);
88
89 /*!
90 * Method defined in <code>CppUnit::TestListener</code>.
91 */
92 void addFailure(const CppUnit::TestFailure &failure);
93
94 /*!
95 * Method defined in <code>CppUnit::TestListener</code>.
96 */
97 void endTest(CppUnit::Test *test);
98
99private:
100 int Connect();
101 void RunTests();
102 void ShutDown();
103
104 // utility methods
105 void ParseCommandLine(int n, char *args[]);
106 void DefineHostName();
107 void InstallListeners();
108 void UninstallListeners();
109
110 /*!
111 * Sends the given test to the CppUnitView.
112 * <p>
113 * In case of test is of type CppUnit::Test the following protocol is sent:
114 * <code>TSTTREE name, false, testCaseCount</code>
115 * </p>
116 * <p>
117 * In case of test is of type CppUnit::TestSuite the following protocol is sent:
118 * TSTTREE name, true, testCount
119 * </p>
120 * @param test the CppUnit test
121 */
122 void SendTestTree(CppUnit::Test *test);
123 void SendMessage(std::string msg);
124
125 // Notification methods
126 void NotifyTestRunStarted(int testCount);
127 void NotifyTestRunEnded(long elapsedTime);
128 void NotifyTestRunStopped(long elapsedTime);
129 void NotifyTestTreeEntry(std::string treeEntry);
130 void NotifyTestStarted(std::string testName);
131 void NotifyTestEnded(std::string testName);
132 void NotifyTestFailed(std::string status, std::string testName, std::string trace);
133
134 std::string GetTrace(const CppUnit::TestFailure &failure);
135 long CurrentTimeMillis();
136 void PrivateSleep(int millisecs);
137};
138
139#endif /*CPPUNIT_MAIN*/
140#endif /*TESTRUNNERSERVER_H_*/
Note: See TracBrowser for help on using the repository browser.