PlatformIO simple c++ unit test example which runs on native (windows) environment


I have a c++ project which runs on my nucleo board. Since it’s getting to some level of maturity I also want to rely more on unit testing (tdd).

I can find plenty of examples how to run unit tests on my target, but that’s not what I am looking for really. I prefer to write tests for my classes and being to run my test suite on my windows PC (I don’t want to be ‘forced’ to upload my code every time I run a test)

I found this example in github
platformio-examples/unit-testing/calculator at develop · platformio/platformio-examples (

But I also read I need to have my own native C++ compiler. I can’t seem to figure out how to get that done. Can I do this from within VS code? Or should I download it manually? Because in that case I guess I also need to configure it properly in VS code.

Some help would be greatly appreciated!

Found this:
GCC for Windows: How to install gcc in Windows 10? (the easier way) - DEV Community

Looks good too, but the easiest way I’ve found is by using the MinGW-W64 project ( One simple installer and it just gives you a nice recent GCC version which you can add to your PATH and you’re done.

1 Like