I found this example on how to create a project with AUnit tests: https://www.thecoderscorner.com/electronics/microcontrollers/embedded-testing/getting-started-unittesting-arduino/
According to it and projects I have found on github my project structure should look like this:
Application
src
SomeComponent.cpp
SomeComponent.h
tests
TestSomeComponent
TestSomeComponent.ino
Application.ino
But when I try to run TestSomeComponent.ino with Arduino IDE or VSC with Arduino plugin it does not see contents of src folder. I am assuming that it is treated as a separate sketch. What is a proper way to build and run tests?
[edit] Some context (not sure what matters):
- Our target board is ESP32 DevKit v1
- Optimally if our developers could run tests on Windows and Linux machines
- I have not gotten yet to continuous integration. I will start automating once I have any test building and running
[edit 2] I have tried command line tools. Got AUniter running and tried like this (hoping for some automagic done by tools):
me@mypc:~/workspace/Application/Application/tests$ auniter.sh test esp32:/dev/ttyUSB0 TestSomeComponent/
I have tried any sane path combination in include path directive, for example:
#include "SomeComponent.h"
#include "app/SomeComponent.h"
#include "../../src/app/SomeComponent.h"
#include <SomeComponent.h>
#include <app/SomeComponent.h>
#include <../../src/app/SomeComponent.h>
But I keep getting this:
TestSomeComponent:4:42: fatal error: ../../src/app/SomeComponent.h: No such file or directory
mkdir ~/Documents/Arduino/libraries/SomeComponent
cp -R src/* ~/Documents/Arduino/libraries/SomeComponent/
and theninclude <SomeComponent.h>
in the test .ino files. That rankles because it means you can't actually unit test a library before installing it. I suspect that's how AUnit/AUniter's author was doing it, though, before they switched away from Arduino IDE/arduino-cli to EpoxyDuino - given all of the AUnit examples use the#include <Foo.h>
style.