Unit testing c++ NCS code

Hi,

Im currently using Cmock and Unity like described here: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/test_and_optimize/testing_unity_cmock.html

the difference is that my usercode is written in c++, which means that I will need to instantiate classes and use strings, vectors etc. in my tests.

I got everything working up until the point where I get undefined reference to `test_suiteTearDown(int)'. when I wrap my code in extern "C"{...} I will get undefined reference to `unity_main'. I think this is due to the unity functions now being compiled with c++ linkage.

this seems to be just a tiny thing that stops me from using this setup for c++ testing but I dont know how to solve it. Any ideas?

I also tried to use Ztest with Cmock instead, but this doesnt work because NCS cmock implementation seems to depend on unity.

I would love if anyone could share some ideas on how to solve this problem.

Kind regards,

Jonas

Related