ESP32 Unit Testing using Unity Framework

I am facing a lot of issues with Unity Test Framework.

pio test
Verbosity level can be increased via -v, -vv, or -vvv option
Collected 1 tests

Processing * in esp32dev environment
----------------------------------------------------------------------------------------------------------------------------------Building & Uploading…
Library Manager: Installing throwtheswitch/Unity @ ^2.6.0

-------------------------------------------- esp32dev:* [ERRORED] Took 65.06 seconds --------------------------------------------

Processing * in native environment
----------------------------------------------------------------------------------------------------------------------------------Building…
.pio\build\native\unity_config_build\unity_config.o: file not recognized: File format not recognized
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\native\program.exe] Error 1
Building stage has failed, see errors above. Use pio test -vvv option to enable verbose output.
---------------------------------------------- native:* [ERRORED] Took 4.90 seconds ----------------------------------------------
============================================================ SUMMARY ============================================================
Environment Test Status Duration


esp32dev * ERRORED 00:01:05.060
native * ERRORED 00:00:04.903
=========================================== 2 test cases: 0 succeeded in 00:01:09.963 ===========================================
PS C:\Users\KMani.Balan\Documents\PlatformIO\Projects\UnitTesting2>

Simple test.cpp file #include <unity.h>

// Function to be tested
int add(int a, int b) {
return a + b;
}

// Test case for addition
void test_add_function() {
TEST_ASSERT_EQUAL(5, add(2, 3));
TEST_ASSERT_EQUAL(0, add(-1, 1));
TEST_ASSERT_EQUAL(-3, add(-1, -2));
}

void setup() {
// Initialize Unity Test Framework
UNITY_BEGIN();

// Run test cases
RUN_TEST(test_add_function);

// End Unity Test Framework
UNITY_END();

}

void loop() {
// Not used in testing; left empty
}

platform.ino

[env:esp32dev]

platform = espressif32

board = esp32dev

framework = arduino

test_ignore = test_desktop

monitor_speed = 115200

lib_deps = throwtheswitch/Unity@2.5.2

[env:native]

platform = native

test_ignore = test_embedded

lib_deps = throwtheswitch/Unity@2.5.2