PlatformIO Community

Unit tests for PIO library

From this post, I’m trying to understand how to run unit tests only on a library (under the lib directory). Any tests in the ./lib/my_lib/test directory aren’t detected and don’t run when testing the project.

  • lib
    –my_lib
    ---- include
    ---- src
    ---- test (Files not found)
  • include
  • src
    – main.cpp
  • test (OK tests are working)

Do I need a separate platformio.ini in each library that I want tests in?

See https://docs.platformio.org/en/latest/plus/unit-testing.html

PIO Unit Testing engine works with projects. You can write tests in a project that cover logic of your libraries/components. See example https://github.com/platformio/platformio-examples/tree/c442de34a57b54451170dbe39f3411a06a05b3f2/unit-testing/calculator