Example of how to write unit tests in C using Unity framework.
There are three important directories:
src
- source codetest
- test casesunity
- unity test framework source
The unity
directory is added as a submodule. Make sure to initialize it after
cloning the project,
$ git submodule init && git submodule update --recursive
The Makefile is the standard Unity make, inspired from here.
Test file names should start with Test*
(case sensitive). Each test file should implement the setUp
, thetearDown
, and the main
functions since this project uses the default Unity test runner.
You need to install make
.
To run tests:
$ make test
To compile the code:
$ make compile
To generate an executable:
$ make install
To run all at once:
$ make
To clean:
$ make clean
To format the code:
$ make format # follow Linux style