This repo seeks to demonstrate the use of cpputest on an arduino project.
It contains:
- The basic arduino blink example
- The cpputest starter project (located in
unit_tests/
) - ArduinoFake(located in
unit_tests/mocks
)
It is failing to compile right now because it is unable to #import "ArduinoFake.h"
There is a single test in unit_tests/tests/
. Right now it will pass because the following 2 lines (suggested on ArduinoFake's getting started section) are commented out:
#include "ArduinoFake.h"
using namespace fakeit;
using Arduino-CLI
- Set environment variables (this FQBN is for the ESP32-nano):
FQBN=arduino:esp32:nano_nora && PORT=</dev/ttyUSB0 OR COM3> && FILENAME=blink-arduino-cpputest.ino
2.Compile
arduino-cli compile --fqbn $FQBN $FILENAME --output-dir build
- Upload
arduino-cli upload -p $PORT --fqbn $FQBN $FILENAME --input-dir build
You can also chain the commands together like so:
arduino-cli compile --fqbn $FQBN $FILENAME --output-dir build && arduino-cli upload -p $PORT --fqbn $FQBN $FILENAME --input-dir build
in case of this error on Linux:
dfu-util: No DFU capable USB device available
download and execute this script
-
Build the docker image (one time only, or on Dockerfile updates):
sudo docker pull jwgrenning/cpputest-runner
-
Run the tests:
./unit-tests/docker/run.sh "make -C unit-tests"
or./unit-tests/docker/run.sh "legacy-build make unit-tests ."
-
Alternatively, install cpputest natively and run
make all
from within theunit_tests
folder