[riot-notifications] [RIOT-OS/RIOT] tests/unittests: rename set_up/tear_down function (#11863)

Aiman Ismail notifications at github.com
Fri Jul 19 11:08:24 CEST 2019


This is not really about precise naming. During my first time writing unit  test, I copy pasted the template and changed all the `<module>` and `<header>` accordingly. That includes `set_up` and `tear_down` in EMB_UNIT_TESTCALLER call:

```
static void set_up(void)
{
    /* omit if not needed */
}

static void tear_down(void)
{
    /* omit if not needed */
}

...

Test *tests_<module>_<header>_tests(void)
{
    .....

    EMB_UNIT_TESTCALLER(<module>_<header>_tests,
                        tests_<module>_<header>_set_up,                <----------- Both of these lines
                        tests_<module>_<header>_tear_down, fixtures);  <-----------
    /* set up and tear down function can be NULL if omitted */

    return (Test *)&<module>_<header>;
}
```

The test failed to build because there is no `tests_<module>_<header>_set_up` and ` tests_<module>_<header>_tear_down`. There is only `set_up` and `tear_down`. After spending a few minutes on it I managed to figure it out and make the changes accordingly.

Because of that I thought maybe it will be easier for newcomers to write their first test in the future with these changes :)

Based on the comments, would it be better if the `set_up` and `tear_down` in EMB_UNIT_TESTCALLER are changed instead?

So the changes would be:
```
Test *tests_<module>_<header>_tests(void)
{
   ...

    EMB_UNIT_TESTCALLER(<module>_<header>_tests,
                        set_up, tear_down, fixtures);
    /* set up and tear down function can be NULL if omitted */

    return (Test *)&<module>_<header>;
}
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11863#issuecomment-513155213
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190719/07ad7d47/attachment.htm>


More information about the notifications mailing list