- Notifications
You must be signed in to change notification settings - Fork0
a modern, portable, cross-language unit testing and mocking framework for C and C++
License
LGPL-2.1, LGPL-2.1 licenses found
Licenses found
matthargett/cgreen
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Do you TDD? In C? Maybe you want to have your tests read out in afluent fashion? Like this
Ensure(Converter, converts_XIV_to_14) { assert_that(convert_roman_to_decimal("XIV"), is_equal_to(14));}
And you want output like this
roman_test.c:12: Failure: Converter -> converts_XIV_to_14 Expected [convert_roman_to_decimal("XIV")] to [equal] [14] actual value: [0] expected value: [14]
ThenCgreen is the thing for you!
Cgreen is a modern unit test and mocking framework for C and C++. Hereare some of Cgreens unique selling points:
- fast build, clean code, highly portable
- auto-discovery of tests without the abuse of static initializers or globals
- extensible without recompiling
- fluent, expressive and readable API with the same modern syntax across C and C++
- process isolation for each test preventing intermittent failuresand cross-test dependencies
- built-in mocking for C, compatible with mockitopp and other C++ mocking libraries
Cgreen has recently moved from SourceForge to GitHub so things are ina bit of a flux. FromSourceForgeyou can get pre-build packages for not-so-old development versions.
ButCgreen is approaching a 1.0 release and things are changing, sofor now an alternative is to download the zip fromGitHub and build ityourself.
You needCmake but most standard C/C++compilers should work. GCC definitely does.
In the root directory runmake
. That will configure and build the Cversion and the C++ version of the libraries.
The documentation is fairly up-to-date. You can read the extensivetutorial directly onGitHub.
You can also build the documentation yourself in HTML and PDF format.Generate it using Asciidoctor, which can be done using the Cmakeconfiguration. Of course you needAsciidoctor.
Navigate to thebuild/build-c
directory. You need to add theWITH_HTML
and/orWITH_PDF
option:
cmake -DWITH_HTML:bool=ON ../..
Runmake
. For example
cd build/build-ccmake -DWITH_HTML:bool=ON -DWITH_PDF:bool=ON ../..make
If there is no licence agreement with this package please downloada version from the location above. You must read and accept thatlicence to use this software. The file is titled simply LICENSE.
What is it? It's a framework for unit testing, written in C. A toolfor C developers writing tests of their own code.
If you have used JUnit, or any of the xUnit clones, you will findthe concept familiar. In particular the tool supports a range ofassertions, composable test suites and setup/teardown facilities.Because of the peculiarities of C programming, each test functionis normally run in it's own process.
This project is very close in scope to the "Check" unit tester andwas influenced by it...http://check.sourceforge.net/projects/check/
The main difference from this tool and other xUnit tools, such as"Check", is that test results are not stored. Instead they arestreamed to the reporter psuedo-class, one that is easilyoverridden by the end user.
The other main extra feature is the support for writing mockcallbacks. This includes generating sequences for return valuesor parameter expectations.
Feedback, queries and request should be put to the cgreen developers throughhttps://github.com/cgreen-devs/cgreen.
This tool is basically a spin off from a research project atWordtracker and would not have happened without the generousfinancial support of the Wordtracker keyword tool...http://www.wordtracker.com/
Substantial inital work by Marcus Bakermarcus@lastcraft.com. Recentadditions by Matt Hargettmatt@use.net, Thomas Nilssonthomas@junovagen.se, João Freitasjoaohf@gmail.com and others.
About
a modern, portable, cross-language unit testing and mocking framework for C and C++
Resources
License
LGPL-2.1, LGPL-2.1 licenses found
Licenses found
Stars
Watchers
Forks
Releases
Packages0
Languages
- C73.8%
- C++11.9%
- CMake11.3%
- Makefile1.1%
- Perl0.8%
- Shell0.7%
- Other0.4%