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?
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.
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.