https://github.com/google/cmockery
A lightweight library to simplify and generalize the process of writing unit tests for C applications.
https://github.com/google/cmockery
c cmockery embedded-systems mocking mocks testing tests unit-testing
Last synced: 13 days ago
JSON representation
A lightweight library to simplify and generalize the process of writing unit tests for C applications.
- Host: GitHub
- URL: https://github.com/google/cmockery
- Owner: google
- License: apache-2.0
- Created: 2015-12-08T17:55:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-05-28T15:20:07.000Z (almost 5 years ago)
- Last Synced: 2025-04-02T05:13:51.345Z (20 days ago)
- Topics: c, cmockery, embedded-systems, mocking, mocks, testing, tests, unit-testing
- Language: Shell
- Homepage:
- Size: 425 KB
- Stars: 1,067
- Watchers: 69
- Forks: 372
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE.txt
Awesome Lists containing this project
README
# Cmockery Unit Testing Framework
[![Build Status][travis-badge]][travis-url]
[travis-badge]: https://travis-ci.org/google/cmockery.svg?branch=master
[travis-url]: https://travis-ci.org/google/cmockery### Contents
* [Overview](#Overview)
* [Building](#Building)
* [Motivation](#Motivation)
* [Community](#Community)Cmockery is a lightweight library that is used to author C unit tests.
Cmockery tests are compiled into stand-alone executables and linked with
the Cmockery library, the standard C library, and the module being tested. Any
symbols external to the module being tested should be mocked - replaced with
functions that return values determined by the test - within the test
application. Even though significant differences may exist between the target
execution environment of a code module and the environment used to test the
code, the unit testing is still valid since its goal is to test the logic of a
code modules at a functional level and not necessarily all of its interactions
with the target execution environment.It may not be possible to compile a module into a test application without
some modification; therefore, the preprocessor symbol `UNIT_TESTING` should
be defined when Cmockery unit test applications are compiled so code within the
module can be conditionally compiled for tests.More detailed information about the mechanics of writing tests with Cmockery can
be found in [`docs/user_guide.md`](docs/user_guide.md).## Building
To compile the Cmockery library and example applications on Linux, run:
~~~
$ ./configure
$ make
~~~To compile on Windows, run:
~~~
> vsvars.bat
> cd windows
> nmake
~~~This code has been tested on Linux (Ubuntu) and Windows using VC++7 and VC++8.
There are a variety of C unit testing frameworks available; however, many of
them are fairly complex and require the latest compiler technology. Some
development requires the use of old compilers which makes it difficult to
use some unit testing frameworks. In addition, many unit testing frameworks
assume the code being tested is an application or module that is targeted to
the same platform that will ultimately execute the test. Because of this
assumption, many frameworks require the inclusion of standard C library headers
in the code module being tested, which may collide with the custom or
incomplete implementation of the C library utilized by the code under test.Cmockery only requires a test application is linked with the standard C
library which minimizes conflicts with standard C library headers. Also,
Cmockery tries avoid the use of some of the newer features of C compilers.This results in Cmockery being a relatively small library that can be used
to test a variety of exotic code. If a developer wishes to simply test an
application with the latest compiler, then other unit testing frameworks may be
preferable.## Community
If you have questions about Cmockery, use the following resources:
* Stack Overflow: use the
[`cmockery`](https://stackoverflow.com/questions/tagged/cmockery) tag
* Mailing list: **cmockery (at) googlegroups.com**
([archives](https://groups.google.com/group/cmockery))To join with a Google account, use the
[web UI](https://groups.google.com/forum/#!forum/cmockery/join); to
subscribe/unsubscribe with an arbitrary email address, send an email to:* cmockery+subscribe (at) googlegroups.com
* cmockery+unsubscribe (at) googlegroups.com## License
Cmockery is licensed under the Apache 2.0 license; please see
[`LICENSE.txt`](LICENSE.txt) for details.