Where to place testing only shared code?

The documentation explains how to structure the tests in a tree under the test/ directory (good). let’s say that I have a few .h and .cpp testing utility files (not tests) which are used by the various tests. Where should I place them in the tree? For example, will test/src and test/include do the trick? How should I #include them?


I’ve had the same problem, no great solution…

Thanks @dvdnwk, this is very useful. I think I will go with the test/common approach because it provides better separation between production and testing code.

… in my case test/common also contain a .cpp file and platformio wouldn’t build it as part of the test which breaks the build. As a workaround I reflect it in each test directory with a wrapper file:


#include "../common/packet_data_test_utils.cpp"

I hope that this feature request will be accepted. It will simplify many things.

1 Like