AUnit
1.5.5
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
|
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()->setVerbosityFlag(verbosity);
112 return getRunner()->isVerbosityFlag(verbosity);
125 getRunner()->setRunnerTimeout(seconds);
133 static const uint8_t kMaxPatternLength = 63 + 1;
139 static uint16_t countTests();
172 exit((mFailedCount || mExpiredCount) ? 1 : 0);
180 if (*mCurrent ==
nullptr) {
186 switch ((*mCurrent)->getLifeCycle()) {
189 (*mCurrent)->enableVerbosity(mVerbosity);
190 (*mCurrent)->setup();
202 (*mCurrent)->enableVerbosity(mVerbosity);
216 unsigned long now = millis();
217 if (mTimeout > 0 && now >= mStartTime + 1000L * mTimeout) {
218 (*mCurrent)->expire();
229 mCurrent = (*mCurrent)->
getNext();
235 switch ((*mCurrent)->getStatus()) {
253 (*mCurrent)->teardown();
257 (*mCurrent)->resolve();
259 *mCurrent = *(*mCurrent)->
getNext();
276 printer->print(F(
"TestRunner test count: "));
277 printer->println(mCount);
279 printer->print(F(
"Test "));
280 (*p)->getName().print(printer);
281 printer->print(F(
"; lifeCycle: "));
282 printer->println((*p)->getLifeCycle());
287 void printStartRunner()
const;
290 void resolveRun()
const;
348 if (mIsSetup)
return;
355 mCount = countTests();
357 mStartTime = millis();
361 void setVerbosityFlag(uint8_t verbosity) { mVerbosity = verbosity; }
364 bool isVerbosityFlag(uint8_t verbosity)
const {
365 return mVerbosity & verbosity;
369 void setLifeCycleMatchingPattern(
const char* pattern, uint8_t lifeCycle);
375 void setLifeCycleMatchingPattern(
const char* testClass,
const char* pattern,
385 Test** mCurrent =
nullptr;
387 bool mIsResolved =
false;
388 bool mIsSetup =
false;
389 bool mIsRunning =
false;
392 uint16_t mPassedCount = 0;
393 uint16_t mFailedCount = 0;
394 uint16_t mSkippedCount = 0;
395 uint16_t mExpiredCount = 0;
396 uint16_t mStatusErrorCount = 0;
398 unsigned long mStartTime;
399 unsigned long mEndTime;
static const uint8_t kLifeCycleFinished
The test has completed its life cycle.
static const uint8_t kStatusFailed
Test has failed, or fail() was called.
static void setPrinter(Print *printer)
Set the output printer.
static const uint8_t kLifeCycleAsserted
Test is asserted (using pass(), fail(), expired() or skipped()) and the getStatus() has been determin...
static const uint8_t kLifeCycleExcluded
Test is Excluded by an exclude() method.
static void list()
Print out the known tests.
static Print * getPrinter()
Get the output printer used by the various assertion() methods and the TestRunner.
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 exclude(const char *testClass, const char *pattern)
Exclude the tests which match the pattern given by (testClass + "_" + pattern), the same concatenatio...
static const uint8_t kDefault
The default verbosity.
static void setVerbosity(uint8_t verbosity)
Set the verbosity flag.
uint16_t TimeoutType
Integer type of the timeout parameter.
static const uint8_t kStatusPassed
Test has passed, or pass() was called.
The class that runs the various test cases defined by the test() and testing() macros.
static void run()
Run all tests using the current runner.
static const uint8_t kStatusExpired
Test has timed out, or expire() called.
static void setTimeout(TimeoutType seconds)
Set test runner timeout across all tests, in seconds.
static bool isVerbosity(uint8_t verbosity)
Returns true if ANY of the bit flags of 'verbosity' is set.
static const uint8_t kStatusSkipped
Test is skipped through the exclude() method or skip() was called.
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.
Test ** getNext()
Return the next pointer as a pointer to the pointer, similar to getRoot().
static Test ** getRoot()
Get the pointer to the root pointer.
static void setPrinter(Print *printer)
Set the printer.
static void include(const char *pattern)
Include the tests which match the pattern.
static const uint8_t kLifeCycleSetup
Test has been set up by calling setup() and ready to execute the test code.