Ceedling Installation – Unit Testing in C Part 3

This article is a continuation of the series on Unit testing in C and carries the discussion on Unit Testing and its implementation. The aim of this series is to provide easy and practical examples that anyone can understand. This is the Ceedling installation procedure – Unit testing in C tutorial Part 3.

You can also read the unit testing introductionceedling installationUnityCmock, and project creation for STM32.

Unit Testing in C – Ceedling Installation


I would recommend you to explore the relevant topics by using the below link.

  1. Unit Testing Introduction
  2. Code Coverage

What is Ceedling?

Ceedling is a Ruby gem that takes care of all the setup, building, and running of C unit tests. Ceedling is primarily targeted at Test-Driven Development in C.  Ceedling includes a test framework (Unity), a mocking framework (CMock), and CException. These are the three other awesome open-source projects you can’t live without if you’re creating awesomeness in the C language.


Unity is an xUnit-style test framework for unit testing C. It is written completely in C and is portable, quick, simple, expressive, and extensible. It is designed to especially be also useful for unit testing for embedded systems.


CMock is an automated stub and mock generation framework made by a community of C developers, including Atom Greg Williams. It works within the Unity testing framework, and it is automatically included in any projects that use the Ceedling build management tool.

CMock autogenerates all functions defined in your code’s header files. It not only generates them, but it gives you additional functionality around those calls.

  • Expectations allow you to specify functions that you expect to be called with specific values by the function under test.
  • Returns allow you to specify what data the mocked function should return to the tested code.
  • Ignores allow you to tell the code to ignore values from expectations if they’re not relevant to the test.
  • Callbacks allow you to specify more complex mocked functionality.


CException is a project released by Throw The Switch. CException is designed to provide simple exception handling in C using the familiar try/catch/throw syntax. The library can be configured for either single-tasking or multi-tasking which makes this project a good fit for embedded systems using an RTOS.
CException is implemented in ANSI C and is highly portable. As long as your system supports the standard library calls setjmp and longjmp, you can use CException in your project. If you’re looking for an exception library to use on embedded systems, CException is for you.


  • Operating System – MS Windows, Linux, Mac OS
  • Supported Technology – C/C++
  • User Interface – Command line

Now we will see how to install Ceedling.

Installing Ceedling

Install the required tools

Ceedling requires both Ruby and GCC to run — so we’ll need to install those first.

Note: Ceedling will be running from the command line, and so you’ll also need to make sure that your path is set up correctly to point to both Ruby and GCC.

Install Ruby

You can find the ruby installer Windows from rubyinstaller.org. The version should be version 1.8.6 or newer.

You have to download the matching installer for your platform it should be either the 32-bit machine or the 64-bit (x64) machine. Once downloaded, please run the installer.

Please use the default installation directories while installing the ruby to make life easier.

Note: Be sure to select the option for Add Ruby executables to your PATH.

When the installer has finished, you can confirm that the installation was successful by opening up a command prompt and running ruby --version:

C:\Users\ceedling-proj>ruby --version
ruby 2.5.1p57 (2018-03-29 revision 63029) [x64-mingw32]

You can also install ruby in the Linux machine by using the below method.

Installing the tools for Linux should be relatively easy. The simplest way to install everything in Linux is with a package manager like apt-get.
Install Ruby with

sudo apt-get install ruby

Install GCC

GCC is the native C compiler used for Ceedling. I will install GCC by using MinGW. But there are many other ways to install GCC. You follow this guide to install the GCC by installing Code Blocks.

Install Ceedling

You can find the Ceedling through the Ruby package manager gem. You should not face any issues when you use the gem command if you have installed the ruby properly. Just run the below command to install the ceedling.

C:\Users\ceedling-proj>gem install ceedling

Wail until it’s installed.

Welcome to Ceedling!
ceedling example PROJ_NAME [DEST] # new specified example project (in DEST...
ceedling examples # list available example projects
ceedling help [COMMAND] # Describe available commands or one spe...
ceedling new PROJECT_NAME # create a new ceedling project
ceedling upgrade PROJECT_NAME # upgrade ceedling for a project (not re...
ceedling version # return the version of the tools installed

That’s it. You can verify that ceedling is installed.

C:\Users\ceedling-proj>ceedling version
Welcome to Ceedling!
Ceedling:: 0.29.1
CMock:: 2.5.1
Unity:: 2.5.0
CException:: 1.3.2

You can check the ceedling version using ceedling version.

That’s all. You have installed ceedling. In our next tutorial, we will see how to use ceedling.

You can also read the below tutorials.

Linux Device Driver TutorialsC Programming Tutorials
FreeRTOS TutorialsNuttX RTOS Tutorials
RTX RTOS TutorialsInterrupts Basics
I2C Protocol – Part 1 (Basics)I2C Protocol – Part 2 (Advanced Topics)
STM32 TutorialsLPC2148 (ARM7) Tutorials
PIC16F877A Tutorials8051 Tutorials
Unit Testing in C TutorialsESP32-IDF Tutorials
Raspberry Pi TutorialsEmbedded Interview Topics
Reset Sequence in ARM Cortex-M4BLE Basics
VIC and NVIC in ARMSPI – Serial Peripheral Interface Protocol
STM32F7 Bootloader TutorialsRaspberry PI Pico Tutorials
STM32F103 Bootloader TutorialsRT-Thread RTOS Tutorials
Zephyr RTOS Tutorials - STM32Zephyr RTOS Tutorials - ESP32
AUTOSAR TutorialsUDS Protocol Tutorials
Product ReviewsSTM32 MikroC Bootloader Tutorial
VHDL Tutorials

Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Newest Most Voted
Inline Feedbacks
View all comments
Table of Contents