Why so many test directories?

I wrote a library with 10 .cpp files that are in the same src directories and now that I that write Unity tests I need to create a separate test directory for each test.

  1. Why? The test runner could exclude on each test build all the other test_xxx.cpp files, so why requiring a complex directory structure?

  2. Is this requirement specific for Unity or for all the test frameworks that platformio supports? I saw for example that one of the frameworks is Google Test, and at google they stuff all the .h, .cpp, and test files of a ‘package’ in the same source directory. Is it the same with platformio?

AFAIK, each (test) directory is built separately.

If you you have 2 CPP test files in one test directory, it will not compile, because you will have multiple main() function definitions “at once”.

Is that the “fault” of Unity or PlatformIO? IDK. I’m guessing PIO’s → as the Unity’s examples have entirely different structure: Unity/examples at master · ThrowTheSwitch/Unity · GitHub

Is that an “issue”? Hmm… maybe? For some? I don’t really mind it that much. It is kinda dumb I’m having gazzilion dirs with one file inside, but whatev, it works.

@dvdnwk , If platformio generates the build commands, it could exclude from the build the other test_x files in that directory, right?

I filled this feature request. Please feel free to vote if you like it. Please support multiple test_xxxx test cases in a single directory · Issue #4641 · platformio/platformio-core · GitHub