I’m not seeing any output for my unit tests and I don’t know why. I am using the PlatformIO plugin for VS code. I have a fresh install of PlatformIO and have set up a blank project and followed the tutorial here. I’m using the arduino nano (new) board. The test is compiling, uploading and running as I see the LED flashing 5 times, I just don’t see any output past
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)
I can however compile and upload a main.cpp program that outputs text in the same environment. Also I’ve run unit tests before with this same setup with no issues. Tests just stopped outputting for some reason
When I inspect the code, I see UNITY_BEGIN() eventually calls UNITY_OUTPUT_START(). I would have thought this is where serial output is initialised, but it’s defined as nothing:
I had a similar issue with GTEST some time ago, here are some suggestions to get started with troubleshooting:
Check if the object files are generated (which should be the case, as you stated your test initiates OK). Files should be located in .pio/build/nanoatmega328new/test/nanoatmega328new
For certain errors, the test itself will just crash without any notification about that or why this happened. Example is a segmentation fault (this is was what happened to me using GTEST and some unnecessary "delete"s on pointers - I just figured it out when running the executable in a console application…)
Your error looks like the test cannot yield the results to display to your terminal.
To investigate, please write a trivial assert right as first and last tests like void trivialTest(void) { TEST_ASSERT_EQUAL(4, 3+1); }
At least the first trivial test should be printed to console if your test crashes due to your implementation of business logic.
In case this does not help, please share a minimal code example that reproduces your error so the community can contribute.
Another possibility are wrong / divergent settings for transfer rates. I’ve made the experience that is a good practice to fix transmission rate in platformio.ini
Right you are!
Same issue arises if you tamper with fuses to change the clock speed, as some libraries have Arduino’s typical Quarz’ed 16Mhz clock hardcoded.
Library/ user code do not realize that the baudrate changes with system clock.
Did not do this with platformio yet, but it was a major hassle to get some Arduino projects running on internal RC oscillator with 1Mhz (on Atmel Studio).
This is where alternative cores like MiniCore (which you can use in either PlatformIO or Arduino IDE ) really shine, as it natively supports 1Mhz clock via the internal oscillator… haven’t tried it myself, but if MCUdude says it works, I believe it!