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