Configure Ceedling for unit testing

I'm starting to look at using Ceedling (+Unity + CMock) for some test driven development but am having trouble getting tests that use/mock the SDK. I'm currently trying to set up unit tests for a custom ble service (an SDK equivalent would be any of the files in the components\ble\ble_services folder) that will run on my PC, not on the target. I am using Cygwin and gcc

Does anyone have any experience/guidance/project files for how to set this up?

My current yml file looks like this


# Notes:
# Sample project C code is not presently written to produce a release artifact.
# As such, release build options are disabled.
# This sample, therefore, only demonstrates running a collection of unit tests.

#  :release_build: TRUE
    - test:all
    - options/

#  :use_assembly: TRUE

#  :output: MyApp.out
#  :use_assembly: FALSE



    - +:test/**
    - -:test/support
    - lib/**
    - include/**
    - test/support



  # in order to add common defines:
  #  1) remove the trailing [] from the :common: section
  #  2) add entries to the :common: section (e.g. :test: has TEST defined)
  :common&common_defines []
    - *common_defines
    - TEST
    - __STATIC_INLINE='static inline'
    - *common_defines
    - TEST

    - :ignore
    - :callback
    uint8:    HEX8
    uint16:   HEX16
    uint32:   UINT32
    int8:     INT8
    bool:     UINT8

# Add -gcov to the plugins list to make sure of the gcov plugin
# You will need to have gcov and gcovr both installed to make it work.
# For more information on these options, see docs in plugins/gcov

# Ceedling defaults to using gcc for compiling, linking, etc.
# As [:tools] is blank, gcc will be used (so long as it's in your system path)
# See documentation to configure a given toolchain for use

# These libraries are automatically injected into the build process. Those specified as
# common will be used in all types of builds. Otherwise, libraries can be injected in just
# tests or releases. These options are MERGED with the options in supplemental yaml files.
  :flag"${1}"  # or "-L ${1}" for example
  :test: []
  :release: []

    - "#{Ceedling.load_path}"
    - stdout_pretty_tests_report
    - module_generator

I am using python to extract include paths and defines from my Keil project file and generate another yml file that I include when running ceedling e.g.

ceedling options:NRF52_S332_SDK153 test:all

this is so i can run tests for each of the targets for my project.

I'm currently stuck with errors like

../libnordic/v15.3/components/softdevice/s332/headers/ble.h: In function 'sd_ble_user_mem_reply':
../libnordic/v15.3/components/softdevice/s332/headers/nrf_svc.h:68:5: error: unknown register name 'r0' in 'asm'
     __asm(                                              \

I have included mock_ble.h in my test file.

#include "unity.h"

#include "ble_my_service.h"
#include "mock_ble.h"
#include "mock_ble_gap.h"

void setUp(void)

void tearDown(void)

void test_ble_my_service_NeedToImplement(void)
    TEST_IGNORE_MESSAGE("Need to Implement ble_my_service");

How can I get this going? Should this work? Am I trying to mock things at too low of a level? Am I using the right compiler tools?

  • Hello,

    to my understanding there is no support for Ceedling. You can read more about it in this post.

  • Sorry for resurrecting an old thread.

    I have Ceedling working well for my project which uses the Nordic SDK + GCC.

    Please be sure to include all relevant defines in your project.yml. Mine looks like this:

      # in order to add common defines:
      #  1) remove the trailing [] from the :common: section
      #  2) add entries to the :common: section (e.g. :test: has TEST defined)
      :common: &common_defines
        - NRF52
        - NRF52832
        - UNIT_TEST
        - FREERTOS
        - *common_defines
        - TEST
        - *common_defines
        - TEST