This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unit testing frameworks for nRF52 for CI/CD and TDD

Hello! I am currently looking at options for unit testing frameworks ( for TDD and CI/CD) on host OS(Windows preferably but Linux if I must) for nRF8233 core custom boards running zephyr application. Would love to hear what the wider community has to say.


a)Ceedling +Unity+ Cmock + virtualized nRF52 using Jumper IO labs virtualization of nRF52 via docker (Then I found Jumper is no longer maintained and only supports nRF52832?)
b)Ceedling +Unity+ Cmock + virtualized nRF52 . AntMicro's renode ticks a lot of my boxes although I see only nRF52840 platform supported among the Nordic parts?
c)zephyr's ztest framework. It appears to be targeted for unit testing on target HW and not for host OS am I right? I really don't want to unit test on target. Both from TDD and CI/CD pov.

Am I missing others?

What's the general consensus here?

Thanks

  • Hi,

    Looking in to the topic and will provide an update.
    Regards,
    Jonathan

  • Hi,

    it depends on what are you planning to unit test. Is it something platform specific? For unit testing of platform independent stuff you can look into ztest. It is basically a zephyr application that for each test function creates a thread and runs it. It can be run on qemu emulators or native_posix target (linux only) so no HW is needed. There is also a runner (twister) that can be used for CI. One thing that ztest lacks is mocking so it's more like a system test.

    Another option is unity port in nRF connect SDK. It is unity+cmock in zephyr context. Similiarly to ztest it is also build as full zephyr application but APIs indicated as the one to be mocked are replaced with mocks (at link time). This path was chosen because there are usually high kconfig/include dependencies in the code so it is hard to compile extracted module. One thing to note is that kernel API cannot be mocked because framework is using kernel API so it cannot be replaced with mocks. See https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_unity_testing.html. Like ztest it can be compiled for qemu, native_posix or  hw platform.

Related