PlatformIO Community

No output when testing

Hi everyone, I could do with some help.

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 :confused:

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:

#define UNITY_OUTPUT_START()

my platformio.ini:

[env:nanoatmega328new]
platform = atmelavr
board = nanoatmega328new
framework = arduino

[env:teensy31]
platform = teensy
framework = arduino
board = teensy31

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 :wink: - 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

[env:d1_mini]
platform = espressif8266
board = d1_mini
test_speed=460800
test_port=/dev/ttyUSB0

as well as in your code

void setup() {
     Serial.begin(460800);
}

If I alter the value for test_speed to a value other than that used in code I observe the same phenomenon like you

1 Like

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