ThrowTheSwitch/CMock

Mock/stub generator for C

C

845

732 commits

updated Oct 17, 2026

See the code

README

CMock CI

CMock is a mock and stub generator and runtime for unit testing C. It's been designed to work smoothly with Unity Test, another of the embedded-software testing tools developed by ThrowTheSwitch.org. CMock automagically parses your C headers and creates useful and usable mock interfaces for unit testing. Give it a try!

If you don't care to manage unit testing builds yourself, consider checking out Ceedling, a test-centered build manager for unit testing C code.

Getting Started

Your first step is to get yourself a copy of CMock. There are a number of ways to do this:

  1. If you're using Ceedling, there is no need to install CMock. It will handle it for you.

  2. The simplest way is to grab it off github. The Github method looks something like this:

    git clone --recursive https://github.com/throwtheswitch/cmock.git

  3. You can also grab the zip file from github. If you do this, you'll also need to grab yourself a copy of Unity and CException, because github unfortunately doesn't bake dependencies into the zip files.

Contributing to this Project

If you plan to help with the development of CMock (or just want to verify that it can perform its self tests on your system) then you can grab its self-testing dependencies, then run its self-tests:

> cd cmock
> bundle install   # Ensures you have all RubyGems needed
> cd test
> rake             # Run all CMock self tests

Before working on this project, you're going to want to read our guidelines on contributing.

API Documentation

c
codegen
mocking
testing

ThrowTheSwitch/CMock

Mock/stub generator for C

C

845

732 commits

updated Oct 17, 2026

See the code

README

CMock CI

CMock is a mock and stub generator and runtime for unit testing C. It's been designed to work smoothly with Unity Test, another of the embedded-software testing tools developed by ThrowTheSwitch.org. CMock automagically parses your C headers and creates useful and usable mock interfaces for unit testing. Give it a try!

If you don't care to manage unit testing builds yourself, consider checking out Ceedling, a test-centered build manager for unit testing C code.

Getting Started

Your first step is to get yourself a copy of CMock. There are a number of ways to do this:

  1. If you're using Ceedling, there is no need to install CMock. It will handle it for you.

  2. The simplest way is to grab it off github. The Github method looks something like this:

    git clone --recursive https://github.com/throwtheswitch/cmock.git

  3. You can also grab the zip file from github. If you do this, you'll also need to grab yourself a copy of Unity and CException, because github unfortunately doesn't bake dependencies into the zip files.

Contributing to this Project

If you plan to help with the development of CMock (or just want to verify that it can perform its self tests on your system) then you can grab its self-testing dependencies, then run its self-tests:

> cd cmock
> bundle install   # Ensures you have all RubyGems needed
> cd test
> rake             # Run all CMock self tests

Before working on this project, you're going to want to read our guidelines on contributing.

API Documentation

c
codegen
mocking
testing

Project health

Overall

3.9/10

Maintained

6/10

Code review

1/10
OpenSSF Scorecard

Significant stargazers

Tristan Partin

91 followers · starred Feb 2022

Joseph Poirier

217 followers · starred Jan 2012

Erlend E. Aasland

121 followers · starred Oct 2025

Sergei Zimmerman

50 followers · starred Feb 2025