Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Unit tests - runner file is not generated

Hi!

I try to set up a unit test environment for my project but I still encounter problems with the runner generation process. 

I have the following project structure

Project

  • submodules
    • a
    • b
    • c
  • src
    • src
    • inc
    • test
      • test_enemy_unknown.c
    • CMakeLists.txt
  • test_upper_level

Everything that is in src is a GIT submodule, so test cases have to be delivered by the repo that is cloned into src dir. That src/CMakeLists.txt contains i.a. two simple lines:

test_runner_generate( ${CMAKE_CURRENT_SOURCE_DIR}/test/test_enemy_unknown.c )
cmock_handle(${ZEPHYR_BASE}/include/drivers/gpio.h drivers)

but if try to build it using WEST (or plain Cmake) I got the message

/home/michal/ProjectsMobica/NRF_Spike/product_nordic_nrf53xx/build/runner/runner_test_enemy_unknown.c

It's true because the runner is not generated anywhere. For testing purposes, I've modified NRF/test/unit/CMakeLists.txt, I added just a simple message to show what exactly the command is called when the runner should be generated... and it looks correctly! If I paste it into the terminal, the runner is generated correctly. So, that's why I suppose the add_custom_command from function test_runner_generate is never called. Mocks are also not generated.

Additionally, If I just move my test directory to the upper-level dir - test_upper_level (I also have to move CMakeLists.txt test-related entries to upper layer CMakeLists.txt) then everything works correctly.

Is it not possible to keep test cases in the lower level directory? Do you know guys how to fix it? 

BTW, I follow this instruction:

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/ug_unity_testing.html

Source of unity extension CMakeLists

https://github.com/nrfconnect/sdk-nrf/blob/master/tests/unity/CMakeLists.txt

Parents Reply Children
No Data
Related