{"id":21363631,"url":"https://github.com/fredericbonnet/picotest","last_synced_at":"2025-07-13T03:31:49.126Z","repository":{"id":38355611,"uuid":"132665586","full_name":"fredericbonnet/picotest","owner":"fredericbonnet","description":"PicoTest is a single-file unit testing framework for C programs that follows the xUnit principles.","archived":false,"fork":false,"pushed_at":"2022-11-19T13:13:07.000Z","size":779,"stargazers_count":15,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-03T04:21:59.812Z","etag":null,"topics":["c","cmake","test-automation","test-framework","testing","testing-framework","testing-tools","tests"],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fredericbonnet.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-08T21:10:12.000Z","updated_at":"2022-08-04T12:00:53.000Z","dependencies_parsed_at":"2022-09-12T03:10:55.233Z","dependency_job_id":null,"html_url":"https://github.com/fredericbonnet/picotest","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fpicotest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fpicotest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fpicotest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fredericbonnet%2Fpicotest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fredericbonnet","download_url":"https://codeload.github.com/fredericbonnet/picotest/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225851340,"owners_count":17534292,"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","cmake","test-automation","test-framework","testing","testing-framework","testing-tools","tests"],"created_at":"2024-11-22T06:20:25.883Z","updated_at":"2025-07-13T03:31:49.118Z","avatar_url":"https://github.com/fredericbonnet.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PicoTest: A minimalist unit testing framework for C programs\n\nPicoTest is a single-file unit testing framework for C programs that follows\nthe xUnit principles:\n\nhttps://en.wikipedia.org/wiki/XUnit\n\n## License\n\nPicoTest is released under the terms of the 3-Clause BSD License:\n\nhttps://opensource.org/licenses/BSD-3-Clause\n\n## Installation\n\nPicoTest is a single-file package, everything is defined in the header file\n`picotest.h`. So you can either install this file in a standard location, or\ncopy it within your project source tree.\n\n## Usage\n\nSimply include the file in your source file, then start writing your tests!\n\n```c\n#include \u003cpicotest.h\u003e\n```\n\n## Documentation\n\nThe complete documentation is available here:\n\nhttps://fredericbonnet.github.io/picotest\n\nThe documentation site was built using these great tools:\n\n- [Doxygen] extracts the documentation from the source code as both HTML and XML\n  formats (the raw HTML output is available [here][htmldocs])\n- [seaborg] converts the XML files to Markdown (full disclosure: I'm the author\n  of this tool!)\n- [docsify] generates the documentation site from the Markdown files\n\nTo rebuild the documentation you'll need the following tools:\n\n- [Doxygen] to process the provided `Doxyfile` and parse the source code\n- [Node.js] to run the build scripts:\n\n```sh\nnpm run docs\n```\n\nIf you want to serve the documentation locally you can use the provided script:\n\n```sh\nnpm run docsify\n```\n\n## Examples\n\nThe `examples` subdirectory contains several example source files that\ndemonstrate the various features of PicoTest. These examples are also integrated\nin the documentation.\n\nBuilding the examples requires the CMake build tool along with your favorite\ntoolchain:\n\nhttps://cmake.org/\n\n## Tests\n\nPicoTest is self-tested and comes with a complete test suite that covers all\naspects of the framework. This guarantees that PicoTest is production-ready.\n\nThe test suite itself is a good real-world example of PicoTest in action.\n\nBuilding and running the test suite requires CMake (see next section for more\ninformation). To build the suite:\n\n```sh\ncd tests\ncmake -S . -B build\ncmake --build build\n```\n\nThe build process makes use of the test discovery mechanism described in the\nnext section.\n\nTo run the suite using CTest:\n\n```sh\ncd tests/build\nctest\n```\n\nYou can also run the suite executable `test_picotest` directly from the CMake\noutput directory.\n\n## Integration with CMake\n\nPicoTest provides a CMake module definition for easier integration with\nother CMake projects. In particular, it comes with an auto-discovery script for\nCTest that makes use of the test traversal features of PicoTest.\n\nThe file `FindPicoTest.cmake` is the module definition. Add this file to your\n`CMAKE_MODULE_PATH`, and add the following line to your CMake project:\n\n```cmake\nfind_package(PicoTest)\n```\n\nYou can then add the `PicoTest` dependency to your targets, e.g.:\n\n```cmake\nadd_executable(my_test_runner)\ntarget_link_libraries(my_test_runner\n    PRIVATE PicoTest\n)\n```\n\nIf you also use CTest for test automation with `enable_testing()`, you can also\ncall the provided `picotest_discover_tests` macro to integrate PicoTest test\ncases in your build process automatically. For example, assuming that the\n`my_test_runner` executable:\n\n- when passed the `-l` option, will list all its test cases using the\n  `PICOTEST_TRAVERSE` feature.\n- when passed `\u003ctest_name\u003e`, will execute the matching test case.\n\nThen the following lines will:\n\n1. execute `my_test_runner -l` as a post-build command to `my_test_runner`,\n2. add each discovered test case using `add_test(\u003ctest_name\u003e)`,\n3. when invoking the `test` rule, execute each test unitarily with\n   `my_test_runner \u003ctest_name\u003e`.\n\n```cmake\nenable_testing()\npicotest_discover_tests(my_test_runner\n    TEST_LIST_OPTION \"-l\"\n)\n```\n\n## Development\n\nPicoTest was developed on Windows 10 and Linux Ubuntu 16.04 using the following\ntools:\n\n- IDE: Visual Studio Code\n- Build tool: CMake 3.15.2\n- Windows toolchain: Microsoft Visual C++ Build Tools 14\n- Linux toolchain: GCC 5.4.0\n\nIt should work with any reasonably modern C compiler that supports variadic\nmacros.\n\nThe assertion mechanism relies on `setjmp()` / `longjmp()`. While these\nfunctions are discouraged for production code, their usage is acceptable in the\ncontext of unit testing: in our case, `longjmp()` is only called when an\nassertion fails, a situation where the actual process state is no longer\nreliable anyway. Moreover, they constitute the only standard exception handling\nmechanism for plain C code.\n\n[docs]: https://fredericbonnet.github.io/picotest\n[htmldocs]: https://fredericbonnet.github.io/picotest/html/index.html\n[doxygen]: http://www.stack.nl/~dimitri/doxygen/\n[seaborg]: https://github.com/fredericbonnet/seaborg\n[docsify]: https://docsify.js.org/\n[node.js]: https://nodejs.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredericbonnet%2Fpicotest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffredericbonnet%2Fpicotest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffredericbonnet%2Fpicotest/lists"}