Skip to content

Unit testing with unity fails on Windows because of Serial.end #5359

@aaronfultonnz

Description

@aaronfultonnz

I've been using the Unity framework for testing code for the RP2040 MCU on Arduino, however I have run into an issue with tests completing cleanly. I've narrowed this down to the call to Serial.end() in void unityOutputComplete(void) { Serial.end(); } [platformio/test/runners/unity.py] which then gets compiled into unity_config.cpp

This causes:

  • Final test results to not always come through
  • A permission denied error (due to closed serial port)
  • Prevents the MCU from software reboots (because the serial is not running), and thus requires manual intervention to run subsequent tests.

I want to know if Serial.end() is necessary here at all? Is there any downside to leaving the Serial running at the end of the test (for Arudino this will sit in loop(), which is normal behavior).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions