We created for you an official series that concentrates on creating a convenient environment for test-driven development for embedded devices and will introduce you to the Unit Testing mechanism used in the PlatformIO ecosystem. Below is a list of the articles in the Unit Testing with PlatformIO series:
Get started with Arduino and ESP32-DevKitC: debugging and unit testing
Get started with ESP-IDF and ESP32-DevKitC: debugging, unit testing, project analysis
Zephyr and Nordic nRF52-DK: debugging, unit testing, project analysis
For the other examples and source code please follow to PlatformIO Unit Testing Examples repository.