No output when unit testing

Hi there,

I’ve been trying to get unit testing working on an STM32 L432KC. I have a class called “Piano” that has a function called “add” that simply adds two numbers passed to the function. I have the following test in the “test” folder:

When I go to run it, I get what is seen above, it says it is testing, but I don’t get any output. I’ve tried resetting the board like the terminal says.

Here is my platformio.ini file:

[env:nucleo_l432kc]
platform = ststm32
board = nucleo_l432kc
framework = mbed
upload_protocol = stlink
debug_tool = stlink
build_flags = -O12 -D PIO_FRAMEWORK_MBED_RTOS_PRESENT
build_unflags = -Os
;monitor_filters = log2file, default
monitor_speed = 115200
build_type = release
test_build_project_src = true

Thank you!

When you manually open a serial monitor at 115200 baud and reset the board, do you see any Unity test run output?

Thanks for the response.

This is what I get when I open a serial terminal manually:

Check if you get something with monitor_speed = 9600, the default mbed-os baudrate might be that.

1 Like

Bingo. That seemed to do it. Thank you, much appreciated. Here’s what I get now:

I’m wondering, how come I don’t get something like this:

This uses the pio test command which parses the serial output in displays it in a pretty way. Previously you just opened the serial monitor and looked at the raw output.

If you use the Test build target you should get similar style output.

After uninstalling and reinstalling the PIO plugin, it seems to be outputting the test results in the PIO terminal now. It’s still not formatting the output all nice like in the photo above, but at least I don’t have to open the serial monitor as well.

Thank you for your help.

Can you show a screenshot of what happens when you execute the Test task?

https://docs.platformio.org/en/latest/integration/ide/vscode.html#task-explorer

Sure thing. In the PIO terminal, I ran “pio test”. I have to press reset on the board for it to show the output. Here’s the output:

Here is the full output:

PS C:\Users\David\Videos\GitLab\Testing_Unit_Testing> pio test
Verbose mode can be enabled via `-v, --verbose` option
Collected 1 items

Processing * in nucleo_l432kc environment
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Building...
Uploading...
In file included from C:\Users\David\.platformio\packages\framework-mbed/drivers/InterruptManager.h:21:0,
                 from C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp:26:
C:\Users\David\.platformio\packages\framework-mbed/platform/CallChain.h:77:37: warning: 'CallChain' is deprecated: CallChain has been deprecated and will be removed. [-Wdeprecated-declarations]
     CallChain : private NonCopyable<CallChain> {
                                     ^~~~~~~~~
C:\Users\David\.platformio\packages\framework-mbed/platform/CallChain.h:77:5: note: declared here
     CallChain : private NonCopyable<CallChain> {
     ^~~~~~~~~
In file included from C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp:26:0:
C:\Users\David\.platformio\packages\framework-mbed/drivers/InterruptManager.h:204:40: warning: 'CallChain' is deprecated: CallChain has been deprecated and will be removed. [-Wdeprecated-declarations]
     CallChain *_chains[NVIC_NUM_VECTORS];
                                        ^
In file included from C:\Users\David\.platformio\packages\framework-mbed/drivers/InterruptManager.h:21:0,
                 from C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp:26:
C:\Users\David\.platformio\packages\framework-mbed/platform/CallChain.h:77:5: note: declared here
     CallChain : private NonCopyable<CallChain> {
     ^~~~~~~~~
C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp: In constructor 'mbed::InterruptManager::InterruptManager()':
C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp:63:60: warning: 'CallChain' is deprecated: CallChain has been deprecated and will be removed. [-Wdeprecated-declarations]
     memset(_chains, 0, NVIC_NUM_VECTORS * sizeof(CallChain *));
                                                            ^
In file included from C:\Users\David\.platformio\packages\framework-mbed/drivers/InterruptManager.h:21:0,
                 from C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp:26:
C:\Users\David\.platformio\packages\framework-mbed/platform/CallChain.h:77:5: note: declared here
     CallChain : private NonCopyable<CallChain> {
     ^~~~~~~~~
C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp: In member function 'bool mbed::InterruptManager::must_replace_vector(IRQn_Type)':
C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp:92:32: warning: 'CallChain' is deprecated: CallChain has been deprecated and will be removed. [-Wdeprecated-declarations]
         _chains[irq_pos] = new CallChain(CHAIN_INITIAL_SIZE);
                                ^~~~~~~~~
In file included from C:\Users\David\.platformio\packages\framework-mbed/drivers/InterruptManager.h:21:0,
                 from C:\Users\David\.platformio\packages\framework-mbed\drivers\source\InterruptManager.cpp:26:
C:\Users\David\.platformio\packages\framework-mbed/platform/CallChain.h:77:5: note: declared here
     CallChain : private NonCopyable<CallChain> {
     ^~~~~~~~~
In file included from C:\Users\David\.platformio\packages\framework-mbed\platform\source\CallChain.cpp:24:0:
C:\Users\David\.platformio\packages\framework-mbed/platform/CallChain.h:77:37: warning: 'CallChain' is deprecated: CallChain has been deprecated and will be removed. [-Wdeprecated-declarations]
     CallChain : private NonCopyable<CallChain> {
                                     ^~~~~~~~~
C:\Users\David\.platformio\packages\framework-mbed/platform/CallChain.h:77:5: note: declared here
     CallChain : private NonCopyable<CallChain> {
     ^~~~~~~~~
C:\Users\David\.platformio\packages\framework-mbed\platform\source\mbed_wait_api_no_rtos.c: In function 'wait':
C:\Users\David\.platformio\packages\framework-mbed\platform\source\mbed_wait_api_no_rtos.c:32:5: warning: 'wait_ms' is deprecated: 'wait_ms' is deprecated in favor of explicit sleep functions. To sleep, 'wait_ms' should be replaced by 'ThisThread::sleep_for' (C++) or 'thread_sleep_for' (C). If you wish to wait (without sleeping), call 'wait_us'. 'wait_us' is safe 
to call from ISR context. [since mbed-os-5.14] [-Wdeprecated-declarations]
     wait_ms(s * 1000.0f);
     ^~~~~~~
In file included from C:\Users\David\.platformio\packages\framework-mbed\platform\source\mbed_wait_api_no_rtos.c:20:0:
C:\Users\David\.platformio\packages\framework-mbed/platform/mbed_wait_api.h:95:6: note: declared here
 void wait_ms(int ms);
      ^~~~~~~
xPack OpenOCD, 64-bit Open On-Chip Debugger 0.10.0+dev (2019-07-17-11:28)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
debug_level: 1

hla_swd
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x08001c5c msp: 0x20010000
** Programming Started **
Warn : block write succeeded
** Programming Finished **
** Verify Started **
** Verified OK **
** Resetting Target **
shutdown command invoked
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)

test\test_add.cpp:17:test_function_add  [PASSED]
-----------------------
1 Tests 0 Failures 0 Ignored
============================================================================ [PASSED] Took 250.49 seconds ============================================================================ 

Test    Environment    Status    Duration
------  -------------  --------  ------------
*       nucleo_l432kc  PASSED    00:04:10.494
============================================================================= 1 succeeded in 00:04:10.494 =============================================================================

That is the correct output. It uploads to the host and gives the [PASSED] for every tested function. Seems like you have moved the test to the dedicated test/ folder now though. The reference screenshot just as more environments (desktop and embedded) and more test functions.

Got it, thank you, much appreciated.

Hi dear developers,

I have also a problem showing the pio test output in a pretty way.
The following scenario I have:

1.) Usingf the Blink_Test prj on my mac → erverything works fine → pretty output works fine

2.) Uning the same projekt on my Windwos pretty output is not shown but the Test works on normal Serial connection.

What do I wrong?
Are there any hints?

Frank

You mean the test results are not shown for you in the official wiring-blink example on Windows?

Hi,
yes screen llok like that:

Don’ matter if you press reset or not.

The test runs, but the pretty nice output don’t work.

Can you explicitly add test_port = <your COM port here> in the platformio.ini for where the ESP is? E.g., COM8.

Fine that works :slight_smile:

Thank you very much.

Does it not automatically take the defines Upload Port?

Indeed – I ran into this too in Unit Testing not working on ESP32 (test port not automatically recognized) · Issue #4076 · platformio/platformio-core · GitHub

This is a bug. I’ve just reopened that issue and will fix it soon.

1 Like