#include <TestRunner.h>
Collaboration diagram for vrj::test::TestRunner:

Public Types | |
| enum | State { Uninitialized, Processing, DoneProcessing } |
Public Methods | |
| TestRunner () | |
| void | initialize (vrj::App *app) |
| Initialize the test suite. More... | |
| void | processTests () |
| Progresses the state of testing Called at the end of preFrame by apps that want to run tests. More... | |
| void | addTest (Test *test) |
| State | getState () |
| Are the tests done processing. More... | |
| void | printFailures () |
| Print out the test failures. More... | |
Protected Attributes | |
| vrj::App * | mApp |
| The application to test. More... | |
| State | mCurState |
| Store the current state of processing. More... | |
| int | mCurTestIndex |
| Index of the current test to run. More... | |
| std::vector< Test * > | mTests |
| List of tests to run. More... | |
| std::vector< TestFailure > | mTestFailures |
| List of test failures. More... | |
Definition at line 58 of file TestRunner.h.
|
|
Definition at line 61 of file TestRunner.h. Referenced by getState.
00062 { Uninitialized,
00063 Processing,
00064 DoneProcessing
00065 };
|
|
|
Definition at line 68 of file TestRunner.h. References mApp, mCurState, mCurTestIndex, and Uninitialized.
00069 : mApp(NULL), mCurState(Uninitialized), mCurTestIndex(-1) 00070 {;} |
|
|
Initialize the test suite. Must be called before running the tests and after all tests have been added. Definition at line 76 of file TestRunner.h. References mApp, mCurState, mTestFailures, mTests, and Processing.
00077 {
00078 mApp = app;
00079
00080 // Initialize the tests
00081 vprASSERT(mTests.size() > 0);
00082 for(unsigned t=0;t<mTests.size();t++)
00083 {
00084 mTests[t]->setApp(app);
00085 }
00086
00087 // Clear the failures
00088 mTestFailures.clear();
00089
00090 mCurState = Processing;
00091 }
|
|
|
Progresses the state of testing Called at the end of preFrame by apps that want to run tests.
Definition at line 96 of file TestRunner.h. References DoneProcessing, mApp, mCurState, mCurTestIndex, mTestFailures, mTests, and printFailures.
00097 {
00098 vprASSERT(NULL != mApp);
00099
00100 bool test_failed(false);
00101
00102 if(mCurTestIndex < (int)mTests.size()) // Check to see if there are tests to run
00103 {
00104 if(-1 == mCurTestIndex) // First time through
00105 {
00106 mCurTestIndex = 0;
00107 std::cout << "TestRunner: Starting test: " << mTests[mCurTestIndex]->getName() << std::endl;
00108 mTests[mCurTestIndex]->setUp(); // Setup the initial test
00109 }
00110 else
00111 {
00112 try
00113 {
00114 mTests[mCurTestIndex]->processTest(); // Process the current test
00115 }
00116 catch(vrj::test::TestFailure& tf)
00117 {
00118 mTestFailures.push_back(tf);
00119 test_failed = true;
00120 }
00121 catch(...)
00122 {
00123 std::cout << "Recieved unknown exception in TestRunner. rethrowing." << std::endl;
00124 throw;
00125 }
00126
00127 if(test_failed || mTests[mCurTestIndex]->isDone()) // If current test is done or failed
00128 {
00129 mTests[mCurTestIndex]->tearDown(); // Tear down the test
00130 mCurTestIndex++; // Goto the next test
00131 if(mCurTestIndex < (int)mTests.size()) // If test is in range
00132 {
00133 std::cout << "TestRunner: Starting test: " << mTests[mCurTestIndex]->getName() << std::endl;
00134 mTests[mCurTestIndex]->setUp(); // - Initialize it
00135 }
00136 else
00137 {
00138 mCurState = DoneProcessing;
00139 printFailures();
00140 }
00141 }
00142 }
00143
00144 }
00145 }
|
|
|
Definition at line 147 of file TestRunner.h. References mTests.
00148 {
00149 mTests.push_back(test);
00150 }
|
|
|
Are the tests done processing.
Definition at line 155 of file TestRunner.h. References mCurState, and State.
00156 { return mCurState; }
|
|
|
Print out the test failures.
Definition at line 161 of file TestRunner.h. References mTestFailures. Referenced by processTests.
00162 {
00163 if(mTestFailures.empty())
00164 {
00165 std::cout << "--- Tests all PASSED!!! ----\n" << std::flush;
00166 }
00167 else
00168 {
00169 std::cout << "----- Test failures: count: " << mTestFailures.size() << " -----\n" << std::flush;
00170
00171 for(unsigned f=0; f<mTestFailures.size(); ++f)
00172 {
00173 TestFailure cur_failure = mTestFailures[f];
00174 std::cout << " Failed: " << cur_failure.getFullDescription() << std::endl;
00175 }
00176 }
00177 }
|
|
|
The application to test.
Definition at line 180 of file TestRunner.h. Referenced by initialize, processTests, and TestRunner. |
|
|
Store the current state of processing.
Definition at line 181 of file TestRunner.h. Referenced by getState, initialize, processTests, and TestRunner. |
|
|
Index of the current test to run. -1 means that we have to start. Definition at line 182 of file TestRunner.h. Referenced by processTests, and TestRunner. |
|
|
List of tests to run.
Definition at line 183 of file TestRunner.h. Referenced by addTest, initialize, and processTests. |
|
|
List of test failures.
Definition at line 184 of file TestRunner.h. Referenced by initialize, printFailures, and processTests. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002