Test_build_src - why is it not recommended

Hello!

I’ve recently been getting into platformio and learning its architecture and how to structure testable code at an enterprise level.

I’ve looked a lot at the recommendation to move components out of the src folder and into the lib folder for it to be testible

it seems like the src folder should really only have a couple files then.

The documentation mentions that you can use the flag test_build_src instead, however recommends against it.

The concern I have is that I can’t find any reasoning behind this and certain libraries such as ArduinoFake seem to rely on this flag being turned on.

Could you provide some clarification around why test_build_src is not recommended? I think myself and other devs find it unnatural to move src code out of the src folder and especially odd to place it in a folder called lib.

Maybe we can use this to improve the docs?

1 Like

Relevant links to documentation:

You may find it funny that I still don’t understand this structure mess… :stuck_out_tongue:

What I did in the end, I actually had to move most of my code to lib, plus separate a lot to make it testable. You can check out a project that was my learning grounds:

It’s not perfect at all, concepts changed with time, not finished features, not finished refactorings, but it used to work and I was getting happy with the direction it was going :wink:

Well - the idea behind that is called Convention over configuration - Wikipedia

let’s call it a convention… i still don’t understand the reasoning behind this particular “convention” – of putting my sources into the lib dir instead of the src dir ;p

Haha thanks! I think I’m in the same boat. Works for me just fine. But unfortunately can’t convince a dev team to conform to it especially when they couldn’t find any reasoning

Convention over configuration says why we should conform and I extremely agree to that. But it doesn’t really explain why the convention is what it is which is more so the point of my question.

To what I’m experiencing, the convention of having src files in a lib folder is causing developers to choose configuration over convention.

So I’m more so curious as to why is platformio’s convention to have files out of the src folder and into the lib folder and why is test_build_src not recommended.

(Not expecting you to have the answers was hoping someone who was involved in those decisions would chime in)

1 Like