platformio-core icon indicating copy to clipboard operation
platformio-core copied to clipboard

Unit test runner shows PASSED in summary when there are failing tests

Open ssilverman opened this issue 6 months ago • 3 comments

I'm seeing the summary showing as passing when there are failures. Many tests pass, then there's a few failures, and my end-of-test summary looks like this (most names are removed for brevity):

...
test/test_math/test_main.cpp:518:PASS
test/test_math/test_main.cpp:519:PASS
test/test_math/test_main.cpp:520:PASS
test/test_math/test_main.cpp:521:PASS
test/test_math/test_main.cpp:522:PASS
test/test_math/test_main.cpp:414:FAIL
test/test_math/test_main.cpp:414:FAIL
test/test_math/test_main.cpp:414:FAIL
test/test_math/test_main.cpp:414:FAIL
test/test_math/test_main.cpp:414:FAIL
test/test_math/test_main.cpp:414:FAIL
test/test_math/test_main.cpp:529:PASS
test/test_math/test_main.cpp:530:PASS
test/test_math/test_main.cpp:531:PASS
...
-----------------------
91 Tests 6 Failures 0 Ignored 
FAIL

The final summary shows PASSED.

I responded to the following issue, but I don't think this is Teensy-specific: https://github.com/platformio/platform-teensy/issues/68

ssilverman avatar Jun 20 '25 18:06 ssilverman

Note that the summary also shows "SKIPPED", even when a test ran with some duration and passed. For example:

teensy41 test_math SKIPPED 00:00:31.206

ssilverman avatar Jun 26 '25 01:06 ssilverman

Note: I usually run with pio test -v.

ssilverman avatar Jun 26 '25 01:06 ssilverman

I've identified and fixed the issue!

Root Cause: In platformio/test/cli.py line 201, the print_suite_footer function was hardcoding "PASSED" for any non-error test status. This caused SKIPPED test suites to incorrectly display as PASSED.

The Fix: Changed to use the actual test_suite.status.name with appropriate color coding via status.to_ansi_color(). Now the footer correctly displays the actual test execution result (PASSED, FAILED, ERRORED, or SKIPPED).

PR: #5302

I've tested this with multiple test scenarios and verified it works correctly for all status types.

SpacePlushy avatar Oct 29 '25 17:10 SpacePlushy