Skip to content

Bug: invalid filename given when assert fails in included subfile #645

@MacDada

Description

@MacDada
/* Test.cpp */
#include <unity.h>
#include "functions.h"

void test_something_specific_to_this_test_file_ok() {
    TEST_ASSERT_TRUE(true);
}

void test_something_specific_to_this_test_file_fail() {
    TEST_ASSERT_TRUE(false); // line 10
}

int main() {
    UNITY_BEGIN();

    RUN_TEST(test_something_specific_to_this_test_file_ok); // line 16
    RUN_TEST(test_something_specific_to_this_test_file_fail); // line 17

    RUN_TEST(test_something_more_universal_from_the_other_file); // line 19

    return UNITY_END();
}
/* functions.h */
#include <unity.h>

void test_something_more_universal_from_the_other_file() {
    TEST_ASSERT_TRUE(false); // line 5
}

The result I get:

Building...
Testing...
test/native/test_including/Test.cpp:16: test_something_specific_to_this_test_file_ok	[PASSED]
test/native/test_including/Test.cpp:10: test_something_specific_to_this_test_file_fail: Expected TRUE Was FALSE	[FAILED]
test/native/test_including/Test.cpp:5: test_something_more_universal_from_the_other_file: Expected TRUE Was FALSE	[FAILED]

Program received signal SIGINT (Interrupt: 2)
----------- native:native/test_including [ERRORED] Took 2.93 seconds -----------

For the last test, the line given 5 is OK, but the filename is wrong: Test.cpp – in reality, the assert that failed is in the functions.h file.

And that makes debugging confusing and hard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions