25 #ifndef AUNIT_TEST_RUNNER_H
26 #define AUNIT_TEST_RUNNER_H
28 #if defined(EPOXY_DUINO)
36 #ifndef SERIAL_PORT_MONITOR
37 #define SERIAL_PORT_MONITOR Serial
58 getRunner()->runTest();
63 getRunner()->listTests();
70 static void exclude(
const char* pattern) {
71 getRunner()->setLifeCycleMatchingPattern(
81 static void exclude(
const char* testClass,
const char* pattern) {
82 getRunner()->setLifeCycleMatchingPattern(testClass, pattern,
90 static void include(
const char* pattern) {
100 static void include(
const char* testClass,
const char* pattern) {
101 getRunner()->setLifeCycleMatchingPattern(testClass, pattern,
107 getRunner()->setLifeCycleMatchingSubstring(
113 getRunner()->setLifeCycleMatchingSubstring(
119 getRunner()->setVerbosityFlag(verbosity);
124 return getRunner()->isVerbosityFlag(verbosity);
137 getRunner()->setRunnerTimeout(seconds);
145 static const uint8_t kMaxPatternLength = 63 + 1;
151 static uint16_t countTests();
184 exit((mFailedCount || mExpiredCount) ? 1 : 0);
192 if (*mCurrent ==
nullptr) {
198 switch ((*mCurrent)->getLifeCycle()) {
201 (*mCurrent)->enableVerbosity(mVerbosity);
202 (*mCurrent)->setup();
214 (*mCurrent)->enableVerbosity(mVerbosity);
228 unsigned long now = millis();
229 if (mTimeout > 0 && now >= mStartTime + 1000L * mTimeout) {
230 (*mCurrent)->expire();
241 mCurrent = (*mCurrent)->
getNext();
247 switch ((*mCurrent)->getStatus()) {
265 (*mCurrent)->teardown();
269 (*mCurrent)->resolve();
271 *mCurrent = *(*mCurrent)->
getNext();
288 printer->print(F(
"TestRunner test count: "));
289 printer->println(mCount);
291 printer->print(F(
"Test "));
292 (*p)->getName().print(printer);
293 printer->print(F(
"; lifeCycle: "));
294 printer->println((*p)->getLifeCycle());
299 void printStartRunner()
const;
302 void resolveRun()
const;
360 if (mIsSetup)
return;
367 processCommandLine();
370 mCount = countTests();
372 mStartTime = millis();
376 void setVerbosityFlag(uint8_t verbosity) { mVerbosity = verbosity; }
379 bool isVerbosityFlag(uint8_t verbosity)
const {
380 return mVerbosity & verbosity;
384 void setLifeCycleMatchingPattern(
const char* pattern, uint8_t lifeCycle);
390 void setLifeCycleMatchingPattern(
const char* testClass,
const char* pattern,
394 void setLifeCycleMatchingSubstring(
395 const char* substring, uint8_t lifeCycle);
404 enum class FilterType : uint8_t {
412 void processCommandLine();
415 int parseFlags(
int argc,
const char*
const* argv);
421 void processCommaList(
const char* commaList, FilterType filterType);
428 Test** mCurrent =
nullptr;
430 bool mIsResolved =
false;
431 bool mIsSetup =
false;
432 bool mIsRunning =
false;
435 bool hasBeenFiltered =
false;
437 uint16_t mPassedCount = 0;
438 uint16_t mFailedCount = 0;
439 uint16_t mSkippedCount = 0;
440 uint16_t mExpiredCount = 0;
441 uint16_t mStatusErrorCount = 0;
443 unsigned long mStartTime;
444 unsigned long mEndTime;
static void setPrinter(Print *printer)
Set the printer.
static Print * getPrinter()
Get the output printer used by the various assertion() methods and the TestRunner.
The class that runs the various test cases defined by the test() and testing() macros.
uint16_t TimeoutType
Integer type of the timeout parameter.
static void include(const char *pattern)
Include the tests which match the pattern.
static bool isVerbosity(uint8_t verbosity)
Returns true if ANY of the bit flags of 'verbosity' is set.
static void setVerbosity(uint8_t verbosity)
Set the verbosity flag.
static void include(const char *testClass, const char *pattern)
Include the tests which match the pattern given by (testClass + "_" + pattern), the same concatenatio...
static void includesub(const char *substring)
Include the tests which match the substring.
static void run()
Run all tests using the current runner.
static void list()
Print out the known tests.
static void setTimeout(TimeoutType seconds)
Set test runner timeout across all tests, in seconds.
static void exclude(const char *testClass, const char *pattern)
Exclude the tests which match the pattern given by (testClass + "_" + pattern), the same concatenatio...
static void setPrinter(Print *printer)
Set the output printer.
static void excludesub(const char *substring)
Exclude the tests which match the substring.
static void exclude(const char *pattern)
Exclude the tests which match the pattern.
static const uint8_t kLifeCycleNew
Test is new, needs to be setup.
static Test ** getRoot()
Get the pointer to the root pointer.
static const uint8_t kLifeCycleSetup
Test has been set up by calling setup() and ready to execute the test code.
static const uint8_t kStatusFailed
Test has failed, or fail() was called.
static const uint8_t kLifeCycleFinished
The test has completed its life cycle.
static const uint8_t kStatusPassed
Test has passed, or pass() was called.
static const uint8_t kStatusExpired
Test has timed out, or expire() called.
static const uint8_t kLifeCycleAsserted
Test is asserted (using pass(), fail(), expired() or skipped()) and the getStatus() has been determin...
static const uint8_t kStatusSkipped
Test is skipped through the exclude() method or skip() was called.
static const uint8_t kLifeCycleExcluded
Test is Excluded by an exclude() method.
Test ** getNext()
Return the next pointer as a pointer to the pointer, similar to getRoot().
static const uint8_t kDefault
The default verbosity.