-
-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Debugging with Unit Testing #948
Comments
In case this feature request looks to complicate, it would be nice to add an API command to print onto Unit Test Terminal. This means no breakpoint, no stack view, but at least we can track some variables while running tests. |
Do you mean _MESSAGE? For example, |
any idea when this feature will be added ? |
Sorry for the delay on this issue. There are some difficulties to implement it. PlatformIO supports multi-level tests with own So, you will be able to declare debug environment and configure which test to debug. For example: [env:debug]
platform = x
framework = y
board = z
build_type = debug
debug_test = yes
test_filter = sometestname Will it work? |
what is current status on this? I am trying to run:
Response is: So I guess it is not implemented ??? |
Sorry for the delay. We planned this feature to upcoming PIO Core 4.4.0. |
I too, would like this feature, or some workaround, for using the debugger while running a test. Seems sort of a strange limitation that you can not debug a test! :-) |
@madsdyd Maybe a solution would be to use cortex debug if you are using VSCode and an ARM mcu (https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug) You can compile the tests .elf file with platformio, then flash it and debug it using cortex debug (you will need a launch.json file) |
As this issue is still open I assume it's not yet fixed. So, a couple of workarounds to suggest.
Work around 1: Command Line
From here on out you should be able to use gdb/openocd to debug the test case. Work around 2: This uses VSCode as the debugger, much easier/nicer
2a: just prior to about line 136 in command.py where is says; add the following "BEFORE" this line. This will read the new variable and disable the normal rebuild of the non test case image: NOTE: be careful of the python required indention, copy and paste
From here you should be able to debug normally using VSCode Note: This has not been approved by Platformio developers, may not work with other release versions, you may get some unusual notifications popup, and of course your mileage may vary, Hopefully I've not missed a step here and hopefully this is helpful. |
See updated docs https://docs.platformio.org/en/latest/plus/debugging.html#debug-unit-tests P.S: @tehnorm, sorry for the delay, and thanks for supporting PlatformIO! 🙏 |
Is there anyway to debug unit tests in native using the the VSCode IDE? I mean using the play button instead of the CLI. I will set the code in a STM32H743, but I have some pure cpp classes and functions in lib that I want to test isolated. Some of the tests are failing and that's why I would like to debug them in native. platformio.ini [env:nucleo_h743zi] [env:native] |
It is often handy to be able to set a breakpoint while debugging a unit test. This is useful when something is hard to track down - being able to see the whole stack/call chain is very helpful.
The text was updated successfully, but these errors were encountered: