platformio-core: Unit Testing not working on ESP32 (test port not automatically recognized)

What kind of issue is this?

  • PlatformIO Core. If you’ve found a bug, please provide an information below.

You can erase any parts of this template not applicable to your Issue.


Configuration

Operating system: Win10 x64

PlatformIO Version (platformio --version): version 5.2.1b4

Description of problem

Unit testing for an ESP32 hangs at the “Testing…” phase.

Steps to Reproduce

  1. Create new blank ESP32 project
  2. Add test/simple_test.cpp from below
  3. Use the project task “Advanced -> Test”

Actual Results

Writing at 0x0003fafb... (100 %)
Wrote 210992 bytes (108452 compressed) at 0x00010000 in 3.1 seconds (effective 536.3 kbit/s)...
Hash of data verified.

Leaving...
Hard resetting via RTS pin...
Testing...
If you don't see any output for the first 10 secs, please reset board (press reset button)

(hangs forever)

Expected Results

Successfull unit test result.

If problems with PlatformIO Build System:

The content of platformio.ini:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino

Source file to reproduce issue:

test\simple_test.cpp

#include <Arduino.h>
#include <unity.h>

void test_led_builtin_pin_number(void) {
    TEST_ASSERT_EQUAL(13, 13);
}

void setup() {
    delay(3000);
    UNITY_BEGIN();
    RUN_TEST(test_led_builtin_pin_number);
    UNITY_END(); // stop unit testing
}

void loop() { }

Additional info

  1. The board is a standard https://www.amazon.de/ESP-32S-ESP32-Development-Bluetooth-Antennenmodul/dp/B071JR9WS9
  2. pio test locks up so that it can’t even killed by Ctrl+C, must be killed in the taskmanager
  3. Increasing the delay() does not help
  4. Explicitly setting test_speed = 115200 does not help
  5. Modifying setup() to Serial.begin(115200); Serial.print("\n\n"); does not help (separates bootloader output from test output)
  6. Setting DTR / RTS states with pio test --monitor-dtr <0/1> --monitor-rts <0/1> does not help
  7. Pressing the reset button on the board does not help
  8. Looking at the serial output after the testing has been aborted at the waiting phase gives

grafik

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

@ivankravets

Works perfectly 💯 🥇

image2

@HareshPrajapati

  1. You don’t need to specify the test port manually. PlatformIO detects it automatically. Could you share the output of pio device list command?
  2. You don’t need to declare setUp/tearDown. They are intended for the Unity testing framework.

Updated