ADTF  3.18.2
testbench.h
Go to the documentation of this file.
1 
7 #ifndef _TEST_BENCH_INCLUDES_
8 #define _TEST_BENCH_INCLUDES_
9 
10 typedef void tTestResult;
11 
15 struct tTestDoc
16 {
17  const tChar* strId;
18  const tChar* strTitle;
20  const tChar* strStrategy;
21  const tChar* strPassedIf;
22  const tChar* strRemarks;
23  const tChar* strFile;
26  const tChar* strUser;
27 };
28 
33 {
34  const tChar* strId;
35  const tChar* strTitle;
38 };
39 
43 class DOEXPORT ITester
44 {
45  public:
49  virtual const tChar* getClassName()
50  {
51  return "unknown";
52  }
53 
57  virtual void setUp()
58  {
59  }
60 
64  virtual void run()
65  {
66  setUp();
67  tearDown();
68  }
69 
73  virtual void tearDown()
74  {
75  }
76 
80  virtual tTestGroupDoc* getDoc()
81  {
82  return nullptr;
83  }
84 };
85 
89 class DOEXPORT ITestReportOutputter
90 {
91  public:
95  typedef enum
96  {
97  OF_Default = 0x0,
98  OF_HidePassed = 0x1,
99  OF_HideFailed = 0x2,
100  OF_HideStatistics = 0x4
101  } tOutputterFlags;
102 
103  public:
108 
113  virtual void setFlags(tInt nFlags) = 0;
114 
118  virtual void beginReport() = 0;
119 
123  virtual void endReport() = 0;
124 
129  virtual void beginTester(ITester* pTester) = 0;
130 
135  virtual void endTester(ITester* pTester) = 0;
136 
141  virtual void writeTestFunction(tTestDoc* pDoc) = 0;
142 
147  virtual void writeTestFunctionEnd(tTestDoc* pDoc) = 0;
148 
159  virtual void writeResult(ITester* pTester,
160  tBool bPassed,
161  const tChar* strExpression,
162  const tChar* strFile,
163  tInt nLine,
164  const tChar* strFunction,
165  const tChar* strMessage) = 0;
166 };
167 
171 class DOEXPORT ITestBench
172 {
173  public:
177  typedef enum
178  {
179  TEST_LOG_UNKNOWN = 0,
180  TEST_LOG_PASSED = 1,
181  TEST_LOG_FAILED = 2
182  } tLogType;
183 
184  public:
189  virtual void* GetEnvironment() = 0;
190 
197  virtual tInt Initialize(tInt argc, const tChar* argv[]) = 0;
198 
203  virtual tInt RunTests() = 0;
204 
209  virtual tInt Shutdown() = 0;
210 
215  virtual void RegisterTester(ITester* pTester) = 0;
216 
221  virtual void LogTestFunction(const tChar* strFunction) = 0;
222 
233  virtual void Log(tInt nLogType,
234  const tChar* strText,
235  const tChar* strExpression,
236  const tChar* strFile,
237  tInt nLine,
238  const tChar* strFunction = nullptr,
239  const tChar* strMessage = nullptr) = 0;
240 
245  virtual void LogStartFunction(tTestDoc* pDoc) = 0;
246 
251  virtual void LogStopFunction(tTestDoc* pDoc) = 0;
252 
257  virtual void RegisterOutputter(ITestReportOutputter* pOutputter) = 0;
258 
263  virtual tBool IsOK() = 0;
264 
271 
277 
283 };
284 
289 
302 extern tInt RunTestBench(tInt argc=0,
303  const tChar* argv[]=nullptr,
304  ITestReportOutputter* pConsoleOutputter=nullptr,
305  tInt nConsoleOutputterFlags=0,
306  ITestReportOutputter* pFileOutputter=nullptr,
307  tInt nFileOutputterFlags=0);
308 
318 
319 #endif // _TEST_BENCH_INCLUDES_
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
void tVoid
The tVoid is always the definition for the void (non-type).
int tInt
type definition for signed integer value (platform and compiler dependent type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
File name class.
Definition: filename.h:59
This interface has to be implemented by the main test program.
Definition: testbench.h:172
virtual A_UTILS_NS::cFilename GetWorkingDir()=0
Returns the tester working dir.
virtual void Log(tInt nLogType, const tChar *strText, const tChar *strExpression, const tChar *strFile, tInt nLine, const tChar *strFunction=nullptr, const tChar *strMessage=nullptr)=0
Generates log output.
virtual A_UTILS_NS::cFilename GetOutputDir()=0
Returns the tester output dir.
virtual tBool IsOK()=0
Returns OK state.
virtual tInt Shutdown()=0
Shutdown of test bench.
virtual tInt Initialize(tInt argc, const tChar *argv[])=0
Initialize test bench.
virtual void RegisterOutputter(ITestReportOutputter *pOutputter)=0
Register test report outputer.
virtual tInt RunTests()=0
Will run all tests.
virtual void * GetEnvironment()=0
virtual void LogStopFunction(tTestDoc *pDoc)=0
Generate log output at stop of function.
virtual void LogStartFunction(tTestDoc *pDoc)=0
Generate log output at start of function.
virtual void LogTestFunction(const tChar *strFunction)=0
Logs test function.
virtual tResult GetPluginDirs(A_UTILS_NS::cStringList &lstDirs)=0
Returns the plugins dir.
virtual void RegisterTester(ITester *pTester)=0
Registers a new tester at the test bench.
This interface has to be implemented by the test report class.
Definition: testbench.h:90
virtual void writeResult(ITester *pTester, tBool bPassed, const tChar *strExpression, const tChar *strFile, tInt nLine, const tChar *strFunction, const tChar *strMessage)=0
Will be called to write the test result.
virtual void beginReport()=0
Will be called when report starts.
virtual void writeTestFunction(tTestDoc *pDoc)=0
Will be called when test case begins.
virtual ~ITestReportOutputter()
Desctructor.
Definition: testbench.h:107
virtual void beginTester(ITester *pTester)=0
Will be called when test begins.
virtual void setFlags(tInt nFlags)=0
Sets flags as specfied in enumeration tOutputterFlags.
virtual void endTester(ITester *pTester)=0
Will be called when test ends.
virtual void writeTestFunctionEnd(tTestDoc *pDoc)=0
Will be called when test case ends.
virtual void endReport()=0
Will be called when report ends.
This class is the base class of all test cases.
Definition: testbench.h:44
virtual tTestGroupDoc * getDoc()
Definition: testbench.h:80
virtual void run()
Will be called when the test has to be performed.
Definition: testbench.h:64
virtual void setUp()
Will be called at start of the run() method.
Definition: testbench.h:57
virtual const tChar * getClassName()
Definition: testbench.h:49
virtual void tearDown()
Will be called at end of the run() method.
Definition: testbench.h:73
This structure defines a test case.
Definition: testbench.h:16
const tChar * strUser
Test user.
Definition: testbench.h:26
const tChar * strShortDesc
Short description.
Definition: testbench.h:19
const tChar * strRequirements
Test requirements.
Definition: testbench.h:25
const tChar * strPassedIf
Which result passes the test.
Definition: testbench.h:21
const tChar * strTitle
Title of test document.
Definition: testbench.h:18
tBool bActive
Test active.
Definition: testbench.h:24
const tChar * strFile
Test file.
Definition: testbench.h:23
const tChar * strStrategy
Test strategy.
Definition: testbench.h:20
const tChar * strRemarks
Remarks for the test.
Definition: testbench.h:22
const tChar * strId
ID of test document.
Definition: testbench.h:17
This structure defines a group of test cases.
Definition: testbench.h:33
const tChar * strShortDesc
Test group short description.
Definition: testbench.h:36
const tChar * strRequirements
Test group requirements.
Definition: testbench.h:37
const tChar * strTitle
Test group title.
Definition: testbench.h:35
const tChar * strId
Test group ID.
Definition: testbench.h:34
tInt RunTestBench(tInt argc=0, const tChar *argv[]=nullptr, ITestReportOutputter *pConsoleOutputter=nullptr, tInt nConsoleOutputterFlags=0, ITestReportOutputter *pFileOutputter=nullptr, tInt nFileOutputterFlags=0)
This function will perform all tests defined in the module.
tVoid OutputDebugStringWrapper(const tChar *strMessage)
This function creates a debug message.
ITestBench * __get_testbench()
This function will return the pointer to the currently active test bench.
void tTestResult
Result type of test methods.
Definition: testbench.h:10