AUnit
1.7.1
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
|
Base class of all test cases. More...
#include <Test.h>
Public Member Functions | |
Test () | |
Empty constructor. More... | |
virtual void | setup () |
Optional method that performs any initialization. More... | |
virtual void | teardown () |
Optional method that performs any clean up after the test ends for any reasons, either passing or otherwise. More... | |
virtual void | loop ()=0 |
The user-provided test case function. More... | |
void | resolve () |
Print out the summary of the current test. | |
const internal::FCString & | getName () const |
Get the name of the test. | |
uint8_t | getLifeCycle () const |
Get the life cycle state of the test. | |
void | setLifeCycle (uint8_t state) |
uint8_t | getStatus () const |
Get the status of the test. | |
void | setStatus (uint8_t status) |
Set the status of the test. More... | |
void | setPassOrFail (bool ok) |
Set the status to Passed or Failed depending on ok. | |
Test ** | getNext () |
Return the next pointer as a pointer to the pointer, similar to getRoot(). More... | |
bool | isDone () const |
Return true if test has been asserted. More... | |
bool | isNotDone () const |
Return true if test is not has been asserted. | |
bool | isPassed () const |
Return true if test is passed. | |
bool | isNotPassed () const |
Return true if test is not passed. | |
bool | isFailed () const |
Return true if test is failed. | |
bool | isNotFailed () const |
Return true if test is not failed. | |
bool | isSkipped () const |
Return true if test is skipped. | |
bool | isNotSkipped () const |
Return true if test is not skipped. | |
bool | isExpired () const |
Return true if test is expired. | |
bool | isNotExpired () const |
Return true if test is not expired. | |
void | skip () |
Mark the test as skipped. More... | |
void | expire () |
Mark the test as expired (i.e. More... | |
void | enableVerbosity (uint8_t verbosity) |
Enable the given verbosity of the current test. | |
void | disableVerbosity (uint8_t verbosity) |
Disable the given verbosity of the current test. | |
Static Public Member Functions | |
static Test ** | getRoot () |
Get the pointer to the root pointer. More... | |
Static Public Attributes | |
static const uint8_t | kLifeCycleNew = 0 |
Test is new, needs to be setup. | |
static const uint8_t | kLifeCycleExcluded = 1 |
Test is Excluded by an exclude() method. More... | |
static const uint8_t | kLifeCycleSetup = 2 |
Test has been set up by calling setup() and ready to execute the test code. More... | |
static const uint8_t | kLifeCycleAsserted = 3 |
Test is asserted (using pass(), fail(), expired() or skipped()) and the getStatus() has been determined. More... | |
static const uint8_t | kLifeCycleFinished = 4 |
The test has completed its life cycle. More... | |
static const uint8_t | kStatusUnknown = 0 |
Test status is unknown. | |
static const uint8_t | kStatusPassed = 1 |
Test has passed, or pass() was called. | |
static const uint8_t | kStatusFailed = 2 |
Test has failed, or fail() was called. | |
static const uint8_t | kStatusSkipped = 3 |
Test is skipped through the exclude() method or skip() was called. | |
static const uint8_t | kStatusExpired = 4 |
Test has timed out, or expire() called. | |
Protected Member Functions | |
void | fail () |
Mark the test as failed. More... | |
void | pass () |
Mark the test as passed. More... | |
void | init (const char *name) |
void | init (const __FlashStringHelper *name) |
bool | isVerbosity (uint8_t verbosity) const |
Determine if any of the given verbosity is enabled. | |
uint8_t | getVerbosity () const |
Get the verbosity. | |
Base class of all test cases.
The test() and testing() macros define subclasses of Test or TestOnce (respectively), and allow the code following the macros in '{}' to become the body of the loop() and once() methods of the two classes (respectively).
aunit::Test::Test | ( | ) |
|
inline |
Mark the test as expired (i.e.
timed out). Use the expireTestNow() macro in a unit test to print a diagnostic message and exit immediately.
|
inlineprotected |
Mark the test as failed.
Use the failTestNow() macro in a unit test to print a diagnostic message and exit immediately.
|
inline |
|
static |
|
inline |
|
pure virtual |
The user-provided test case function.
Each call to Test::run() makes one call to this loop() method. The assertXxx() macros, as well as pass(), fail() and skip() functions can be called in here.
Implemented in aunit::TestOnce, and aunit::TestAgain.
|
inlineprotected |
Mark the test as passed.
Often used to terminate a testing() looping test. The passTestNow() macro can be used in a unit test to print a diagnostic message and exit immediately. It is expected that pass() will be used more often.
|
inline |
Set the status of the test.
All changes to getStatus() should happen through this method because it also changes the getLifeCycle() of the test.
|
inlinevirtual |
Optional method that performs any initialization.
The assertXxx() macros, as well as pass(), fail() and skip() functions can be called in here. Subclasses that override this should call the parent's setup() method in the first line so that the setup() methods in the inheritance tree are properly chained.
|
inline |
Mark the test as skipped.
Use the skipTestNow() macro in a unit test to print a diagnostic message and exit immediately.
|
inlinevirtual |
Optional method that performs any clean up after the test ends for any reasons, either passing or otherwise.
Subclasses that override this should call the parent's teardown() method in the last line before returning, so that the teardown() methods in the inheritance tree are properly chained.
|
static |
Test is asserted (using pass(), fail(), expired() or skipped()) and the getStatus() has been determined.
The teardown() method should be called.
|
static |
Test is Excluded by an exclude() method.
The setup() and teardown() methods are bypassed and the test goes directly to kLifeCycleFinished. For reporting purposes, an excluded test is counted as a "skipped" test. The include() method puts the test back into the kLifeCycleNew state.
|
static |
|
static |
Test has been set up by calling setup() and ready to execute the test code.
TestOnce tests (i.e. test() or testF()) should be in Setup state only for a single iteration. TestAgain tests (i.e. testing() or testingF()) will stay in Setup state until explicitly moved to a different state by the testing code (or the test times out).