Add runStartup category to UnitTest

This commit is contained in:
Vinnie Falco
2013-08-01 14:25:20 -07:00
parent 1a37c99b87
commit 290627d741
3 changed files with 51 additions and 13 deletions

View File

@@ -258,7 +258,28 @@ void UnitTests::runAllTests ()
{
UnitTest* const test = allTests [i];
if (test->getWhen () == UnitTest::runAlways)
if (test->getWhen () == UnitTest::runNormal)
{
tests.add (test);
}
}
runTests (tests);
}
void UnitTests::runStartupTests ()
{
UnitTest::TestList const& allTests (UnitTest::getAllTests ());
Array <UnitTest*> tests;
tests.ensureStorageAllocated (allTests.size ());
for (int i = 0; i < allTests.size(); ++i)
{
UnitTest* const test = allTests [i];
if (test->getWhen () == UnitTest::runStartup)
{
tests.add (test);
}
@@ -279,7 +300,9 @@ void UnitTests::runTestsByName (String const& name)
{
UnitTest* const test = allTests [i];
if (test->getPackageName () == name && test->getWhen () == UnitTest::runAlways)
if (test->getPackageName () == name &&
(test->getWhen () == UnitTest::runNormal ||
test->getWhen () == UnitTest::runStartup))
{
tests.add (test);
}

View File

@@ -67,16 +67,28 @@ class UnitTests;
class BEAST_API UnitTest : public Uncopyable
{
public:
/** When the test should be run.
Tests that run always will be incuded in all tests or in a group test.
Manual tests will only run when they are individually targeted. This
lets you leave out slow tests or peformance tests from the main test set.
*/
/** When the test should be run. */
enum When
{
runAlways,
runManual
/** Test will be run when @ref runAllTests is called.
@see runAllTests
*/
runNormal,
/** Test will excluded from @ref runAllTests.
The test can be manually run from @ref runTestsByName.
@see runAllTests, runTestsByName
*/
runManual,
/** Test will be additionlly forced to run on every launch.
If any failures occur, FatalError is called. The tests will
also be run from @ref runAllTests or @ref runTestsByName if
explicitly invoked.
@see FatalError
*/
runStartup
};
/** Describes a single test item.
@@ -172,7 +184,7 @@ public:
*/
explicit UnitTest (String const& name,
String const& group = "",
When when = runAlways);
When when = runNormal);
/** Destructor. */
virtual ~UnitTest();
@@ -358,10 +370,13 @@ public:
void runTests (Array <UnitTest*> const& tests);
/** Runs all the UnitTest objects that currently exist.
This calls runTests() for all the objects listed in UnitTest::getAllTests().
This calls @ref runTests for all the objects listed in @ref UnitTest::getAllTests.
*/
void runAllTests ();
/** Runs the startup tests. */
void runStartupTests ();
/** Run a particular test or group. */
void runTestsByName (String const& name);