AUnit  0.3.1
Unit testing framework for Arduino platforms inspired by ArduinoUnit.
Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | List of all members
aunit::Test Class Referenceabstract

Base class of all test cases. More...

#include <Test.h>

Inheritance diagram for aunit::Test:
Inheritance graph
[legend]

Public Member Functions

 Test (const char *name)
 Constructor taking the name of the given test case. More...
 
 Test (const __FlashStringHelper *name)
 Constructor taking the name of the given test case. More...
 
virtual void setup ()
 Optional method that performs any initialization. More...
 
virtual void loop ()=0
 The user-provided test case function. More...
 
const FCStringgetName ()
 Get the name of the test. More...
 
uint8_t getStatus ()
 Get the status of the test. More...
 
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. More...
 
Test ** getNext ()
 Return the next pointer as a pointer to the pointer, similar to getRoot(). More...
 
bool isDone ()
 Return true if test is done (passed, failed, skipped, expired). More...
 
bool isNotDone ()
 Return true if test is done (passed, failed, skipped, expired). More...
 
bool isPassed ()
 Return true if test is passed. More...
 
bool isNotPassed ()
 Return true if test is passed. More...
 
bool isFailed ()
 Return true if test is failed. More...
 
bool isNotFailed ()
 Return true if test is failed. More...
 
bool isSkipped ()
 Return true if test isNot skipped. More...
 
bool isNotSkipped ()
 Return true if test isNot skipped. More...
 
bool isExpired ()
 Return true if test is expired. More...
 
bool isNotExpired ()
 Return true if test is expired. More...
 
void skip ()
 Mark the test as skipped. More...
 
void expire ()
 Mark the test as expired (i.e. More...
 

Static Public Member Functions

static Test ** getRoot ()
 Get the pointer to the root pointer. More...
 

Static Public Attributes

static const uint8_t kStatusNew = 0
 Test is new, needs to be setup. More...
 
static const uint8_t kStatusSetup = 1
 Test is set up. More...
 
static const uint8_t kStatusPassed = 2
 Test has passed, or pass() was called. More...
 
static const uint8_t kStatusFailed = 3
 Test has failed, or failed() was called. More...
 
static const uint8_t kStatusSkipped = 4
 Test is skipped, through the exclude() method or skip() was called. More...
 
static const uint8_t kStatusExpired = 5
 Test has timed out, or expire() called. More...
 

Protected Member Functions

void fail ()
 Mark the test as failed. More...
 
void pass ()
 Mark the test as passed. More...
 

Detailed Description

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).

Definition at line 100 of file Test.h.

Constructor & Destructor Documentation

◆ Test() [1/2]

aunit::Test::Test ( const char *  name)
explicit

Constructor taking the name of the given test case.

Also performs self-registration into the linked list of all test cases defined by Test::getRoot().

Definition at line 38 of file Test.cpp.

◆ Test() [2/2]

aunit::Test::Test ( const __FlashStringHelper *  name)
explicit

Constructor taking the name of the given test case.

Also performs self-registration into the linked list of all test cases defined by Test::getRoot()..

Definition at line 45 of file Test.cpp.

Member Function Documentation

◆ expire()

void aunit::Test::expire ( )
inline

Mark the test as expired (i.e.

timed out).

Definition at line 210 of file Test.h.

◆ fail()

void aunit::Test::fail ( )
inlineprotected

Mark the test as failed.

Definition at line 214 of file Test.h.

◆ getName()

const FCString& aunit::Test::getName ( )
inline

Get the name of the test.

Definition at line 158 of file Test.h.

◆ getNext()

Test** aunit::Test::getNext ( )
inline

Return the next pointer as a pointer to the pointer, similar to getRoot().

This makes it much easier to manipulate a singly-linked list. Also makes setNext() method unnecessary.

Definition at line 174 of file Test.h.

◆ getRoot()

Test ** aunit::Test::getRoot ( )
static

Get the pointer to the root pointer.

Implemented as a function static so fixes the C++ static initialization problem making it safe to use this in other static contexts.

Definition at line 33 of file Test.cpp.

◆ getStatus()

uint8_t aunit::Test::getStatus ( )
inline

Get the status of the test.

Definition at line 161 of file Test.h.

◆ isDone()

bool aunit::Test::isDone ( )
inline

Return true if test is done (passed, failed, skipped, expired).

Definition at line 177 of file Test.h.

◆ isExpired()

bool aunit::Test::isExpired ( )
inline

Return true if test is expired.

Definition at line 201 of file Test.h.

◆ isFailed()

bool aunit::Test::isFailed ( )
inline

Return true if test is failed.

Definition at line 189 of file Test.h.

◆ isNotDone()

bool aunit::Test::isNotDone ( )
inline

Return true if test is done (passed, failed, skipped, expired).

Definition at line 180 of file Test.h.

◆ isNotExpired()

bool aunit::Test::isNotExpired ( )
inline

Return true if test is expired.

Definition at line 204 of file Test.h.

◆ isNotFailed()

bool aunit::Test::isNotFailed ( )
inline

Return true if test is failed.

Definition at line 192 of file Test.h.

◆ isNotPassed()

bool aunit::Test::isNotPassed ( )
inline

Return true if test is passed.

Definition at line 186 of file Test.h.

◆ isNotSkipped()

bool aunit::Test::isNotSkipped ( )
inline

Return true if test isNot skipped.

Definition at line 198 of file Test.h.

◆ isPassed()

bool aunit::Test::isPassed ( )
inline

Return true if test is passed.

Definition at line 183 of file Test.h.

◆ isSkipped()

bool aunit::Test::isSkipped ( )
inline

Return true if test isNot skipped.

Definition at line 195 of file Test.h.

◆ loop()

virtual void aunit::Test::loop ( )
pure virtual

The user-provided test case function.

EEach 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.

◆ pass()

void aunit::Test::pass ( )
inlineprotected

Mark the test as passed.

Definition at line 217 of file Test.h.

◆ setPassOrFail()

void aunit::Test::setPassOrFail ( bool  ok)

Set the status to Passed or Failed depending on ok.

Definition at line 54 of file Test.cpp.

◆ setStatus()

void aunit::Test::setStatus ( uint8_t  status)
inline

Set the status of the test.

Definition at line 164 of file Test.h.

◆ setup()

virtual void aunit::Test::setup ( )
inlinevirtual

Optional method that performs any initialization.

The assertXxx() macros, as well as pass(), fail() and skip() functions can be called in here.

Definition at line 148 of file Test.h.

◆ skip()

void aunit::Test::skip ( )
inline

Mark the test as skipped.

Definition at line 207 of file Test.h.

Member Data Documentation

◆ kStatusExpired

const uint8_t aunit::Test::kStatusExpired = 5
static

Test has timed out, or expire() called.

Definition at line 121 of file Test.h.

◆ kStatusFailed

const uint8_t aunit::Test::kStatusFailed = 3
static

Test has failed, or failed() was called.

Definition at line 115 of file Test.h.

◆ kStatusNew

const uint8_t aunit::Test::kStatusNew = 0
static

Test is new, needs to be setup.

Definition at line 106 of file Test.h.

◆ kStatusPassed

const uint8_t aunit::Test::kStatusPassed = 2
static

Test has passed, or pass() was called.

Definition at line 112 of file Test.h.

◆ kStatusSetup

const uint8_t aunit::Test::kStatusSetup = 1
static

Test is set up.

Definition at line 109 of file Test.h.

◆ kStatusSkipped

const uint8_t aunit::Test::kStatusSkipped = 4
static

Test is skipped, through the exclude() method or skip() was called.

Definition at line 118 of file Test.h.


The documentation for this class was generated from the following files: