mirror of
https://github.com/unittest-cpp/unittest-cpp
synced 2026-09-27 00:28:49 +03:00
71 lines
2 KiB
C++
71 lines
2 KiB
C++
#ifndef UNITTEST_TESTRUNNER_H
|
|
#define UNITTEST_TESTRUNNER_H
|
|
|
|
#include "Test.h"
|
|
#include "TestList.h"
|
|
#include "CurrentTest.h"
|
|
|
|
namespace UnitTest {
|
|
|
|
class TestReporter;
|
|
class TestResults;
|
|
class Timer;
|
|
|
|
UNITTEST_LINKAGE int RunAllTests();
|
|
|
|
/**
|
|
* Commands:
|
|
* --suite One or multiple suite names to execute, can be combined with --test
|
|
* --test One or multiple test names to execute, can be combined with --suite
|
|
* --ignoretest One or multiple test parameter name, with index(es) specified, using this syntax: pzMyParam[4,8,12,7]
|
|
*
|
|
* Usage example: myTests.exe --suite MySuite1 MyOtherSuite --test MySpecialTest MyOtherTest --ignoreparam pzMyPlatforms[0,2,3] pzMyParam[4,8]
|
|
*/
|
|
UNITTEST_LINKAGE int RunTestsCmd(int argc, char**argv, char const* suiteArgument = "--suite", char const* testArgument = "--test", char const* ignoreParamArgument = "--ignoreparam");
|
|
|
|
struct True
|
|
{
|
|
bool operator()(const Test* const) const
|
|
{
|
|
return true;
|
|
}
|
|
};
|
|
|
|
class UNITTEST_LINKAGE TestRunner
|
|
{
|
|
public:
|
|
explicit TestRunner(TestReporter& reporter);
|
|
~TestRunner();
|
|
|
|
template< class Predicate >
|
|
int RunTestsIf(TestList const& list, char const* suiteName,
|
|
const Predicate& predicate, int maxTestTimeInMs) const
|
|
{
|
|
TestListNode* curTest = list.GetHead();
|
|
|
|
while (curTest != 0)
|
|
{
|
|
if (IsTestInSuite(curTest->m_test, suiteName) && predicate(curTest->m_test))
|
|
RunTest(m_result, curTest->m_test, maxTestTimeInMs);
|
|
|
|
curTest = curTest->m_next;
|
|
}
|
|
|
|
return Finish();
|
|
}
|
|
|
|
TestResults* GetTestResults();
|
|
|
|
private:
|
|
TestReporter* m_reporter;
|
|
TestResults* m_result;
|
|
Timer* m_timer;
|
|
|
|
int Finish() const;
|
|
bool IsTestInSuite(const Test* const curTest, char const* suiteName) const;
|
|
void RunTest(TestResults* const result, Test* const curTest, int const maxTestTimeInMs) const;
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|