Testing
PlatformIO unit tests take a substantial amount of the overall code base: About one third in LOC (lines of code) and more then 50% in number of files are occupied by unit tests. The code base consists of almost 500 test cases.
Many tests are sensitive to Feature flags. In particular the low level tests
may require the -DANABRID_PEDANTIC
flag to be set.
In PlatformIO, tests are standalone firmware images. That means they have their own
entry point (setup()
function) or Arduino-style top level functions setup()
and loop()
, respectively. Running a test requires building the test, uploading it
and immediately launching it, printing the outcome of the test suite. This might have
surprising outcomes. For instance, once the test firmware image is flashed to the teensy,
it remains there even after power loss. The teensy will run the test (either once
or within a loop, depending on your code) after being powered up again.
Limitations
In some cases, the code base overstrains or misuses the test concept in order to enable the developers to write little standalone programs within the overall firmware API.
Tests should be used for automatic evaluation of pass/fail criteria. Tests are
generally not suitable for passing large amounts of data from the microcontroller
to the client. Some tests excessively communicate with TEST_MESSAGE(...)
macros which are hidden by default. You explicitely need to enable these tests
with the verbosity flags -v
, -vv
or even -vvv
. This has, however, the
downside that you most likely get a lot of unintended output from the host side
testing framework next to the actual teensy output.