Using parameterized tests with unity

Hi,

To make it easier to write, maintain and check unittests, I would like to use the parameterized testing feature of unity (see unity documentation on github). By default parameterized testing is disabled and to use it, it needs to be enabled by adding :use_param_tests: true to the :unity element in the unity.cfg.yaml file.

When building unittests (based on the examples) the file is generated as part of the test_runner_generate(src/my_test.c) command in CMakeLists.txt. It is generated from a template file in the nRF SDK (~/ncs/v2.5.0/nrf/tests/unity/unity_cfg.yaml.template in my case). If I add the configuration option to this file I can use the parameterized test feature, but changing one of the sdk files is not a good and/or workable option.

So, how can I enable this option without overriding the sdk file?

I've looked at the cmake functions, but I can't figure out a way to override its behavior and/or provide my own template, other then rolling my own version of the test_runner_generate function; which is far from ideal too.

Any help is appreciated.

Kind regards,

Rhyaldir

Parents Reply Children
  • Heard back from our developers:

    "I wasn't adding this template file to CMakeLists.txt but i see that it is fixed there. Probably it could be changed to come from Kconfig to allow user overwriting it. I made a draft https://github.com/nrfconnect/sdk-nrf/pull/14720"

    And

    "

    it's not directly supported, meaning we have not created an interface for this usecase, however CMake supports overriding of functions, which in this case could be achieved the following way:

    • Create a user defined Zephyr module (could be users own manifest repo) and have this module depending upon nrfmodule.
    • Override configure_unity_conf_file()in the user defined Zephyr module, so that the user's own macro is used instead of NCS default.

    "

Related