#Need help adding Unity tests to my existing PlatformIO project

2 messages · Page 1 of 1 (latest)

ocean granite
#

Hi all, I'm having trouble adding testing to my medium-sized embedded project. I'm using VS Code + PlatformIO on Windows and Mac, and would like to stay in that IDE/environment. The platform is Arduino ESP32, using C++17.

I've been looking at Doctest, Unity, and testMate. What I would really like is step-by-step instructions for adding tests to an existing project (preferably in such a way that the test code is not included with production builds). All the instructions I can find start from an empty project. This doesn't help me, as I'm having build errors when I try to build my project for testing.

I'm trying Unity and doctest, and getting the issue that PlatformIO isn't finding the tests in its Testing sidebar. Also, header files aren't being found when I compile the tests. I have no idea how PlatformIO finds dependencies, or why it have trouble in one place but not another.

  • Copying my production [env:xxx] as [env:text_xxx] and just adding test_framework = doctest (same build flags and platform and lib_deps and everything), I get errors like "fatal error: WiFi.h: No such file or directory". WiFi.h is definitely available, as the production build environment runs just fine.
  • Using a simple [env:test_xxx] with test_framework = doctest and platform = native: Compiling ./lib/foo/foo.cpp, the compiler can't find header files in my project that live in a sister directory ./lib/bar/bar.h. It compiles fine for the production build environment.
inland ironBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.