I have recently been using Platformio to develop an ESP32 program. The program leverages the IoAbstraction library and I am trying to unit test my program, however when running a simple native unit test it fails to compile when I #include <MockIoAbstraction.h> indicating the library cannot be found.
The native calculator example (
https://github.com/platformio/platformio-examples/tree/develop/unit-testing/calculator) compiles and runs on my Windows 10 PC (compiler is Mingw).
When I add the IOAbstraction library using the Platformio IDE and add modify my plaformio.ini env as follows:
[env:native]
platform = native
test_ignore = test_embedded
lib_deps = davetcc/IoAbstraction@^1.6.7
the library is shown in the IDE under pio/libdeps/native folder.
I add the line
#include <IoAbstraction.h>
to test_desktop/test_calculator.cpp and attempt to run the test which fails to compile with the following result/error message:
Processing test_desktop in native environment
--------------------------------------------------------------------------------------------------------------------------------------------------------Building...
test\test_desktop\test_calculator.cpp:19:10: fatal error: MockIoAbstraction.h: No such file or directory
***************************************************************************
* Looking for MockIoAbstraction.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:MockIoAbstraction.h"
* Web >
https://platformio.org/lib/search?query=header:MockIoAbstraction.h
*
***************************************************************************
#include <MockIoAbstraction.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\native\test\test_desktop\test_calculator.o] Error 1
============================================================== [FAILED] Took 0.83 seconds ==============================================================
Test Environment Status Duration
------------ ------------- -------- ------------
test_common native PASSED 00:00:00.832
test_desktop native FAILED 00:00:00.830
======================================================== 1 failed, 1 succeeded in 00:00:01.663 ========================================================
I'm not sure what to do next, and looking for any suggestions as to how to get platformio to see the library and successfully compile this test. Thanks in advance for any pointers or examples to help get me started unit testing with MockIoAbstraction.h