https://github.com/kasramp/c-unit-testing
Example of how to write unit tests in C programming language
https://github.com/kasramp/c-unit-testing
c c-lang c-language cprogramming cunittest
Last synced: 12 months ago
JSON representation
Example of how to write unit tests in C programming language
- Host: GitHub
- URL: https://github.com/kasramp/c-unit-testing
- Owner: kasramp
- License: gpl-3.0
- Created: 2023-05-19T14:43:31.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2023-05-20T21:37:16.000Z (almost 3 years ago)
- Last Synced: 2025-03-25T09:21:56.623Z (about 1 year ago)
- Topics: c, c-lang, c-language, cprogramming, cunittest
- Language: C
- Homepage:
- Size: 33.2 KB
- Stars: 5
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# C unit testing
Example of how to write unit tests in C using [Unity](https://github.com/ThrowTheSwitch/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,
```bash
$ git submodule init && git submodule update --recursive
```
The Makefile is the standard Unity make, inspired from [here](http://www.throwtheswitch.org/build/make).
Test file names should start with `Test*` (case sensitive). Each test file should implement the `setUp`, the`tearDown`, and the `main` functions since this project uses the default Unity test runner.
## How to run
You need to install `make`.
To run tests:
```bash
$ make test
```
To compile the code:
```bash
$ make compile
```
To generate an executable:
```bash
$ make install
```
To run all at once:
```bash
$ make
```
To clean:
```bash
$ make clean
```
To format the code:
```bash
$ make format # follow Linux style
```