r89m / AxxTest

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AxxTest

AxxTest is a unit testing framework for Arduino and Arduino-compatible code built upon the CxxTest unit testing framework and the FakeIt Mocking Framework.

Supported Hardware Features

In its current form it allows testing of pure C++ code as well as code making use of simple I/O and built-in functions such as:

  • digitalRead

  • digitalWrite

  • analogRead

  • analogWrite

  • millis

  • SerialUSB

Setup

This framework requires make and g++. Please see the example project's setup instructions for details.

Assert Methods

In order to test some of the Arduino-specific code, it is necessary to use one of the new Assert methods that AxxTest provides:

  • TS_ASSERT_PIN_MODE(pin, mode); - asserts that the given pin is set to the given mode

  • TS_ASSERT_DIGITAL_WRITE(pin, state); - asserts that the given pin is set to the given state

  • TS_ASSERT_ANALOG_WRITE(pin, value); - asserts that the given pin is set to the given value

AxxTest_ Methods

Several AxxTest_ prefixed methods are provided to allow dummy values to be provided to the code under test.

  • AxxTest_millis(new_millis) - set the value that millis() will return, effectively controlling time.

  • AxxTest_digitalRead(pin, state) - set the state of a digital pin that will be read later by the code under test.

  • AxxTest_analogRead(pin, value) - set the value of an analog pin that will be read later by the code under test.

Example

Please see the example project to see how tests can be implemented to verify the functioning of your code that uses the above methods.

About

License:Other


Languages

Language:C++ 48.5%Language:Python 40.2%Language:XSLT 5.8%Language:C 2.4%Language:Ruby 0.8%Language:Shell 0.8%Language:Perl 0.7%Language:Makefile 0.5%Language:CMake 0.1%Language:Smarty 0.1%Language:Hack 0.0%Language:Batchfile 0.0%