mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Add 'print' unit test which prints the list of tests
This commit is contained in:
@@ -323,11 +323,11 @@ public:
|
|||||||
{
|
{
|
||||||
beginTestCase ("backtrace");
|
beginTestCase ("backtrace");
|
||||||
|
|
||||||
pass ();
|
|
||||||
|
|
||||||
String const s = SystemStats::getStackBacktrace ();
|
String const s = SystemStats::getStackBacktrace ();
|
||||||
|
|
||||||
Logger::outputDebugString (s);
|
logMessage (s);
|
||||||
|
|
||||||
|
pass ();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -351,3 +351,46 @@ void UnitTests::runTest (UnitTest& test)
|
|||||||
Throw (std::runtime_error ("unhandled exception during unit tests"));
|
Throw (std::runtime_error ("unhandled exception during unit tests"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/** A UnitTest that prints the list of available unit tests.
|
||||||
|
Not an actual test (it always passes) but if you run it manually it
|
||||||
|
will print a list of the names of all available unit tests in the program.
|
||||||
|
*/
|
||||||
|
class UnitTestsPrinter : public UnitTest
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
UnitTestsPrinter () : UnitTest ("print", "print", runManual)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void runTest ()
|
||||||
|
{
|
||||||
|
beginTestCase ("List available unit tests");
|
||||||
|
|
||||||
|
TestList const& list (UnitTest::getAllTests ());
|
||||||
|
|
||||||
|
for (int i = 0; i < list.size (); ++i)
|
||||||
|
{
|
||||||
|
UnitTest const& test (*list [i]);
|
||||||
|
|
||||||
|
String s;
|
||||||
|
switch (test.getWhen ())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
case UnitTest::runNormal: s << " "; break;
|
||||||
|
case UnitTest::runManual: s << "[manual] "; break;
|
||||||
|
case UnitTest::runStartup: s << "[FORCED] "; break;
|
||||||
|
};
|
||||||
|
|
||||||
|
s << test.getPackageName () << "/" << test.getClassName ();
|
||||||
|
|
||||||
|
logMessage (s);
|
||||||
|
}
|
||||||
|
|
||||||
|
pass ();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static UnitTestsPrinter unitTestsPrinter;
|
||||||
|
|||||||
Reference in New Issue
Block a user