Skip to content

Example of how to write unit tests in C programming language

License

Notifications You must be signed in to change notification settings

kasramp/c-unit-testing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C unit testing

Example of how to write unit tests in C using Unity framework.

Project structure

There are three important directories:

  • src - source code
  • test - test cases
  • unity - 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.

How to run

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

About

Example of how to write unit tests in C programming language

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published