{"id":19149947,"url":"https://github.com/cgreen-devs/cgreen","last_synced_at":"2025-05-07T04:45:34.723Z","repository":{"id":1655245,"uuid":"41703892","full_name":"cgreen-devs/cgreen","owner":"cgreen-devs","description":"A modern, portable, cross-language unit testing and mocking framework for C and C++","archived":false,"fork":false,"pushed_at":"2024-11-09T15:05:36.000Z","size":3425,"stargazers_count":177,"open_issues_count":56,"forks_count":47,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-05-07T04:45:25.498Z","etag":null,"topics":["c","cplusplus","mocking-framework","tdd","tdd-utilities","unittesting"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cgreen-devs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2015-08-31T22:30:55.000Z","updated_at":"2025-04-09T06:51:18.000Z","dependencies_parsed_at":"2023-09-25T23:38:09.117Z","dependency_job_id":"5f4e0c21-23e9-4ba6-b290-1da1826fbc65","html_url":"https://github.com/cgreen-devs/cgreen","commit_stats":{"total_commits":1651,"total_committers":43,"mean_commits":"38.395348837209305","dds":0.7437916414294368,"last_synced_commit":"98c2550efcc30b1e47aa7501c62d93dfcf493f1e"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgreen-devs%2Fcgreen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgreen-devs%2Fcgreen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgreen-devs%2Fcgreen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cgreen-devs%2Fcgreen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cgreen-devs","download_url":"https://codeload.github.com/cgreen-devs/cgreen/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252816520,"owners_count":21808702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","cplusplus","mocking-framework","tdd","tdd-utilities","unittesting"],"created_at":"2024-11-09T08:10:09.276Z","updated_at":"2025-05-07T04:45:34.698Z","avatar_url":"https://github.com/cgreen-devs.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://app.travis-ci.com/cgreen-devs/cgreen.svg?branch=master)](https://app.travis-ci.com/github/cgreen-devs/cgreen)\n[![Coverage Status](https://coveralls.io/repos/cgreen-devs/cgreen/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/cgreen-devs/cgreen?branch=master)\n\n![](https://github.com/cgreen-devs/cgreen/blob/master/doc/logo.png?s=300)\n\n\nCgreen - The Modern Unit Test and Mocking Framework for C and C++\n=================================================================\n\nDo you TDD? In C or C++? Maybe you want to have your tests read out in\na fluent fashion? Like this\n\n    Ensure(Converter, converts_XIV_to_14) {\n        assert_that(convert_roman_to_decimal(\"XIV\"), is_equal_to(14));\n    }\n\nAnd you want output like this\n\n    roman_test.c:12: Failure: Converter -\u003e converts_XIV_to_14\n            Expected [convert_roman_to_decimal(\"XIV\")] to [equal] [14]\n                    actual value:                   [0]\n                    expected value:                 [14]\n\nThen *Cgreen* is the thing for you!\n\n**TLDR;** The full tutorial is on\n[github.io](https://cgreen-devs.github.io/cgreen/cgreen-guide-en.html).\nOr have a look at the [cheat sheet](https://cgreen-devs.github.io/cgreen/cheat-sheet.html).\n\n## What It Is\n\nCgreen is a modern unit test and mocking framework for C and C++.\nHere are some of Cgreens unique selling points:\n\n  - fast build, clean code, highly portable\n  - auto-discovery of tests without the abuse of static initializers or globals\n  - extensible without recompiling\n  - fluent, expressive and readable API with the same modern syntax across C and C++\n  - process isolation for each test preventing intermittent failures\n    and cross-test dependencies\n  - built-in mocking for C, compatible with mockitopp and other C++ mocking libraries\n  - expressive and clear output using the default reporter\n  - fully functional mocks, both strict, loose and learning\n  - mocks with side effects\n  - extensive and expressive constraints for many datatypes\n  - custom constraints can be constructed by user\n  - bdd-flavoured test declarations with Before and After declarations\n  - extensible reporting mechanism\n  - fully composable test suites\n  - a single test can be run in a single process for easier debugging\n\n## Getting It\n\nCgreen is hosted on [GitHub](https://github.com/cgreen-devs/cgreen).\nAs of now there are no pre-built packages to download, but Cgreen is available in [Debian, Fedora and some other package repositories](https://repology.org/project/cgreen/versions), although some are lagging.\n\nThere are also some other packaging scripts available, not all official:\n\n  - [PACMAN script](https://github.com/voins/cgreen-pkg)\n  - [MacOS packagesbuild](https://github.com/cgreen-devs/cgreen-macosx-packaging)\n  - [Cygwin package script](https://github.com/cgreen-devs/cgreen-cygport)\n\nYou can also clone the repository or download the source zip from [GitHub](http://www.github.com/cgreen-devs/cgreen) and build it yourself.\n\n## Building It\n\nYou need the [CMake](http://www.cmake.org) build system.\nMost standard C/C++ compilers should work. GCC definitely does.\n\nPerl, diff, find and sed are required to run Cgreen's own\nunit-tests. Most distro will have those already installed.\n\nIn the root directory run ``make``. That will configure and build the\nlibrary and the `cgreen-runner`, both supporting both C and C++. See\nalso the documentation.\n\n## Using It\n\nTests are fairly easy write, as shown by the examples in the beginning\nof this readme. You should probably read the\n[tutorial](https://cgreen-devs.github.io/cgreen/cgreen-guide-en.html) once before writing your\nfirst test, though.\n\nBasically you can run your tests in two ways\n\n1. Compile and link all your tests with a test driver (as shown in the\n   fist chapters of the tutorial)\n2. Link your tests into separate shared libraries (`.so`, `.dylib` or\n   similar) and run them with the `cgreen-runner` (described in chapter\n   6 of the tutorial)\n\nOption 2 is very handy, you can run multiple libraries in the same\nrun, but also specify single tests that you want to run. And with the\ncompletion script available for bash you can get TAB-completion not\nonly for files and options but also for tests inside the libraries.\n\n`cgreen-debug` is a small script that you invoke in the same way as\nthe runner but runs a single, specified, test and puts you in the\ndebugger at the start of that test. Awesome!\n\n## Using Cgreen in other CMake projects\nOnce Cgreen is installed you can use ``find_package(cgreen)`` in your CMake\nprojects to get access to useful variables like ``${CGREEN_LIBRARIES}``,\n``${CGREEN_EXECUTABLE}`` and ``${CGREEN_INCLUDE_DIRS}``. Version can be\nspecified in ``find_package`` as well. For example, in order to enforce a minimum\nversion of Cgreen in your project use ``find_package(cgreen 1.1.0)``\n\n## Reading Up!\n\nYou can read the extensive tutorial directly on\n[GitHub](https://cgreen-devs.github.io/cgreen/cgreen-guide-en.html).\n\nThere is a [cheat sheet](https://github.com/cgreen-devs/cgreen/blob/master/doc/cheat-sheet.md)\navailable.\n\nYou can also build the documentation yourself in HTML and PDF format.\nGenerate it using Asciidoctor, which can be done using the CMake\nconfiguration. Of course you need\n[Asciidoctor](http://www.asciidoctor.org).\n\n    make doc\n    make pdf\n\n(Generating PDF also requires [asciidoctor-pdf](https://asciidoctor.org/docs/asciidoctor-pdf/).)\n\n## License\n\nCgreen is licensed under the ISC License\n(http://spdx.org/licenses/ISC), sometimes known as the OpenBSD\nlicense. If there is no licence agreement with this package please\ndownload a version from the location above. You must read and accept\nthat licence to use this software. The file is titled simply LICENSE.\n\n## The Original Version\n\nWhat is it? It's a framework for unit testing, written in C. A tool\nfor C developers writing tests of their own code.\n\nIf you have used JUnit, or any of the xUnit clones, you will find\nthe concept familiar. In particular the tool supports a range of\nassertions, composable test suites and setup/teardown facilities.\nBecause of the peculiarities of C programming, each test function\nis normally run in it's own process.\n\nThis project is very close in scope to the \"Check\" unit tester and\nwas initially influenced by it.\n\nThe main difference from this tool and other xUnit tools, such as\n\"Check\",  is that test results are not stored. Instead they are\nstreamed to the reporter psuedo-class, one that is easily\noverridden by the end user.\n\nThe other main extra feature is the support for writing mock\ncallbacks. This includes generating sequences for return values\nor parameter expectations.\n\nFeedback, queries and request should be put to the cgreen developers\nthrough https://github.com/cgreen-devs/cgreen.\n\nThis tool is basically a spin off from a research project at\nWordtracker and would not have happened without the generous\nfinancial support of the Wordtracker keyword tool...\nhttp://www.wordtracker.com/\n\nSubstantial inital work by Marcus Baker \u003cmarcus@lastcraft.com\u003e. Recent\nadditions by Matt Hargett \u003cmatt@use.net\u003e, Thomas Nilefalk\n\u003cthomas@junovagen.se\u003e, João Freitas \u003cjoaohf@gmail.com\u003e and others.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgreen-devs%2Fcgreen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcgreen-devs%2Fcgreen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcgreen-devs%2Fcgreen/lists"}