Getting output of failed test?

I’ve been enjoying coming up to speed on PIO unit testing, especially the ability to test natively. A recent test running natively uncovered a memory bug, which is great, but it took me a while to figure out what was going on. When I run pio test -e native, instead of getting any kind of dump or output related to the error, I just saw the red text saying that the test had FAILED.

I get that you’d want to trap exceptions so testing could proceed, but is there any way to dump whatever output was generated during the failure to see what happened?

Thanks!

Does the device execute the unit tests on start? Have you looked the pure UART output with just miniterm.py for example?

Hi, and thanks for your response! In this situation I’m running the tests with “native” target, so they’re compiled and run on my Mac and not on the device.

I have this exact issue, was there ever a solution?

Thanks

Can you provide the project in which your issue occurs?

I think PlatformIO has been updated and we now get a segfault output in the log if we forget to stub an Arduino method:

Program errored with 3221225477 code

If you get this error, check to make sure you’ve added a stubs for all Arduino methods you are calling.

Can you file that directly in Issues · platformio/platformio-core · GitHub so that it reaches the developers?

Hi @maxgerhardt, sorry for the confusion. It’s not an issue but rather relating my experience (my post was badly worded). I’ve updated it to be (hopefully) clearer!

For anyone else getting this issue, try running your tests with the -v or --verbose flags, ie platformio test -e native -v.
The converts the following output:

Collected 1 tests

Processing * in native environment
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Building...
Testing...
Program received signal SIGHUP (Hangup)
------------------------------------------------------------- native:* [ERRORED] Took 0.81 seconds -------------------------------------------------------------

to

Collected 1 tests (*)

Processing * in native environment
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
Building...


Testing...
Randomness seeded to: 847155196

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
program is a Catch2 v3.2.1 host application. (160)
Run with -? for options

---------------------------------------------------------------------------------------------------------------------------------------------------------------
Example failing test
---------------------------------------------------------------------------------------------------------------------------------------------------------------
test/test-example.cpp:43
...............................................................................................................................................................

Unknown file:0: FAILED:
explicitly with message:
  Unexpected method invocation: unknown()
    An unmocked method was invoked. All used virtual methods must be stubbed!

===============================================================================================================================================================
test cases:  8 |  7 passed | 1 failed
assertions: 11 | 10 passed | 1 failed

Program received signal SIGHUP (Hangup)
------------------------------------------------------------- native:* [ERRORED] Took 4.86 seconds -------------------------------------------------------------

where, in my case, I’d forgotten to mock a method.

1 Like