Arduino Mega Unit testing - Testing... If you don't see any output for the first 10 secs, please reset board (press reset button)

Hello, I’m using VSC with PlatformIO extension installed running on Windows 11, i’m using a arduino Uno and a Arduino Mega for a project each one with it unique enviroment, i can build and upload code but when i tried the unit testing it gets stuck in the mesage:

Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)

Things that I already tried:

  1. Setting a test_port and a port_speed
  2. Using a extra script to make a delay after the dowload, code below:
import time

Import("env")

if "test" in env.GetBuildType():
    env.AddPostAction("upload", lambda *_, **__: time.sleep(2))
  1. Testing only the uno or the mega, but i get the same result
  2. Made a code extremely simple as test to make sure it wasn’t it, code below:
#include <unity.h>
#include <unity_config.h>
#include <Arduino.h>

void setUp() {

}

void tearDown() {

}

void test_blink() {
    TEST_ASSERT_EQUAL(1, 1);
}

void setup() {
    delay(5000);
    UNITY_BEGIN();
    RUN_TEST(test_blink);
    UNITY_END();
}

void loop() {}

I don’t know if it’s gonna help but this is my platformio.ini

[env:mega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
upload_port = COM6
test_port = COM6
monitor_speed = 9600
test_speed = 9600
test_build_src = false
build_src_filter = +<receiver.cpp>
test_filter = test_env_mega2560
extra_scripts = post:extra_script.py
build_flags = -I test/
lib_deps = 
    arduino-libraries/SD@^1.3.0
    adafruit/Adafruit Fingerprint Sensor Library@^2.1.3
    adafruit/Adafruit GFX Library@^1.11.11
    prenticedavid/MCUFRIEND_kbv@^3.1.0-Beta
    adafruit/Adafruit BusIO@^1.16.2
    adafruit/Adafruit TouchScreen@^1.1.5
    Wire @ ^1.0
    SPI @ ^1.0
    SoftwareSerial @ ^1.0
    throwtheswitch/Unity@^2.6.0

[env:uno]
platform = atmelavr
board = uno
framework = arduino
upload_port = COM9
test_port = COM9
monitor_speed = 9600
test_speed = 9600
test_build_src = false
build_src_filter = +<transmitter.cpp>
test_filter = test_env_uno
extra_scripts = post:extra_script.py
build_flags = -I test/
lib_deps = 
    arduino-libraries/SD@^1.3.0
    adafruit/Adafruit Fingerprint Sensor Library@^2.1.3
    adafruit/Adafruit GFX Library@^1.11.11
    prenticedavid/MCUFRIEND_kbv@^3.1.0-Beta
    adafruit/Adafruit BusIO@^1.16.2
    adafruit/Adafruit TouchScreen@^1.1.5
    Wire @ ^1.0
    SPI @ ^1.0
    SoftwareSerial @ ^1.0
    throwtheswitch/Unity@^2.6.0

So i’m completly out of ideas on how to make this work.

When you take this exact project

and change board = uno to board = megaatmega2560 in the platformio.ini, do the tests run?

1 Like

Hello, they actually do! I don’t know the difference between this project and mine but i’ll figure it out.

Thank you very much!

So I found the solution!!

If anyone reading this have the same problem, check if you have the unity library manualy installed, if you see in my platformio.ini, throwtheswitch/Unity@^2.6.0 is in the lib_deps. Remove from the platformio.ini and the Unity folder of the library and let the platformio do its magic, it will install it automatically when you build your project. For me that was enough to get the tests up and running.

Again thanks @maxgerhardt for helping me!