Unity / Unit Test app

Gabriel_Simmann
Posts: 4
Joined: Thu Jul 20, 2023 7:16 am

Unity / Unit Test app

Postby Gabriel_Simmann » Wed Aug 09, 2023 10:01 am

Hi there,

i am trying to implement unit tests for my project. Therefore i found the following documentations:
https://docs.espressif.com/projects/esp ... tests.html
https://github.com/espressif/esp-idf/tr ... t-test-app
https://github.com/espressif/esp-idf/tr ... /unit_test

I tried every way (directly via unity and via the unit test app) but couln't get it to work unfortunately.
It gets so far that the project builds, flashes and the test menu of the unit test app shows up, but it doesn't show the test cases i included into the test subdirectory of the component i want to test. There it shows the following error for when i try to implement a test case in the following way:

Code: Select all

#include <limits.h>
#include "unity.h"

TEST_CASE("test name", "[fails]")
{
    TEST_ASSERT_EQUAL(1, 1);
}
Error:
"expected a type specifier" for both of the arguments ("test name" and "[fails]")

Does someone know what could be wrong so it doesn't take those two arguments?

Thanks!

ESP_igrr
Posts: 2072
Joined: Tue Dec 01, 2015 8:37 am

Re: Unity / Unit Test app

Postby ESP_igrr » Fri Aug 11, 2023 5:10 pm

Hi Gabriel_Simmann,

Could you please check whether you have CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER option enabled in sdkconfig? Perhaps the issue is due to the fact that the feature which provides these TEST_CASE macros is disabled.
Another thing to try, what happens if you add this additional file into the unit_test example? Try placing it into $IDF_PATH/examples/system/unit_test/components/testable/, next to test_mean.c, then build the project under unit_test/test subdirectory.

Gabriel_Simmann
Posts: 4
Joined: Thu Jul 20, 2023 7:16 am

Re: Unity / Unit Test app

Postby Gabriel_Simmann » Fri Aug 18, 2023 9:11 am

Hi ESP_igrr,

thanks for the answer and information! I had a look into it and the mentioned option is enabled in my project.
Furthermore, when i use the unit_test example this error doesn't show up.

In the meantime i managed to get the tests to work, but the error is still there. So now it is acceptable, but still i would like to get rid of these errors, as it makes the project look ugly :D

If anyone has any more suggestions for this, i would appreciate it very much!

Cheers,
Gabriel

Who is online

Users browsing this forum: Bing [Bot] and 171 guests