PlatformIO Community

How to use the TEST_ASSERT_EQUAL_INT_MESSAGE Method

Hello , i am pretty new with platform IO and not so seasoned with Unit Test so maybe this is a silly question.

i am developing a c++ embedded software project, for this project i write unit test for each module of code and all Working fine.
but i want to print message with each unit test case , i find some inbuild method in unity.h file for message print on serial monitor. i write unit test with this [TEST_ASSERT_EQUAL_INT_MESSAGE] Method but it didn’t print the message on serial monitor.
define the test_monitor = 115200 in platform.ini file

what should i do for printing message with test case.
thanks in advance

I can’t reproduce the problem you’re having.

The macro, as stated in Unity’s documentation, is intended to throw a message if the test fails. If I write a simple test/test_macro.cpp as

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

void test_supposed_to_fail(void) {
    int a = 1;
    int b = 2;
    TEST_ASSERT_EQUAL_INT_MESSAGE(a, b, "A and B do not match!11");
}


void setup() {
    // NOTE!!! Wait for >2 secs
    // if board doesn't support software reset via Serial.DTR/RTS
    delay(2000);

    UNITY_BEGIN();
    RUN_TEST(test_supposed_to_fail);
    UNITY_END();
}

void loop() { }

And press the “Test” button…

grafik

Works nicely.

Thanks, I get it now.