{"id":21861540,"url":"https://github.com/raleighlittles/minimal-gtest-example","last_synced_at":"2025-03-21T20:19:11.943Z","repository":{"id":117726403,"uuid":"151774345","full_name":"raleighlittles/Minimal-GTest-Example","owner":"raleighlittles","description":"A very very minimal example of how to configure and run GTest, Google's C++ testing framework.","archived":false,"fork":false,"pushed_at":"2018-10-06T00:58:30.000Z","size":199,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T14:52:36.426Z","etag":null,"topics":["cmake-examples","cmakelists","cpp","google-test","gtest","ubuntu","unit-testing-framework"],"latest_commit_sha":null,"homepage":"https://github.com/google/googletest","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raleighlittles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-10-05T20:26:38.000Z","updated_at":"2023-12-08T04:21:31.000Z","dependencies_parsed_at":null,"dependency_job_id":"186eb24c-b1f3-410b-aaac-ab2b7ab85e6e","html_url":"https://github.com/raleighlittles/Minimal-GTest-Example","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raleighlittles%2FMinimal-GTest-Example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raleighlittles%2FMinimal-GTest-Example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raleighlittles%2FMinimal-GTest-Example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raleighlittles%2FMinimal-GTest-Example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raleighlittles","download_url":"https://codeload.github.com/raleighlittles/Minimal-GTest-Example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244860600,"owners_count":20522466,"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":["cmake-examples","cmakelists","cpp","google-test","gtest","ubuntu","unit-testing-framework"],"created_at":"2024-11-28T03:11:56.812Z","updated_at":"2025-03-21T20:19:11.918Z","avatar_url":"https://github.com/raleighlittles.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About\n\nThis is a *very* simple example of how to run GTest (Google Test) on a Ubuntu 16+ machine.\n\nFor more information about Google Test, check out the official [Google Test Repo](https://github.com/google/googletest) and specifically, the [GTest Primer](https://github.com/google/googletest/blob/master/googletest/docs/primer.md).\n\n# Instructions\n\n## Installing GTest onto your system\n\n* Start by installing `libgtest-dev`:\n\n```bash\nsudo apt-get install libgtest-dev\n```\n\n* Navigate to where the files were installed, which is usually: `/usr/src/gtest/` if you installed them using the command above.\n\n```bash\ncd /usr/src/gtest/\n```\n\n* Use C-Make to create the build files.\n\n```bash\nsudo cmake CMakeLists.txt\n```\n\n* Once the build and makefiles are created you can just run:\n\n```bash\n\nsudo make\n```\n\n* Copy the newly-built library into your libraries folder, which for Ubuntu is `/usr/lib/`.\n\n```bash\nsudo cp *.a /usr/lib/\n```\n\n## Running GTest\n\nTo truly make this example minimal, we'll only use 2 files: a source code file and a test file.\n\n* `fake_class.hpp` is a source file that contains two methods. \n* `fake_class_tests.cpp` contains tests for those methods. \n\n\n## Building an executable\n\nOnce you have your two files, all that is needed is to build them together. All modern C++ IDEs support auto-generating Makefiles/CMake files but if yours does not, then you can use the one provided.\n\nThis means you can simply just run: \n\n```bash\ncmake CMakeLists.txt\n```\n\nand then \n\n```bash\nmake \n```\n\nto create your executable\n\n**CMake Users**: If you would like to use your own custom CMakeFile, then at the very least it must include the following lines to be able to use GTest:\n\n```\nfind_package(GTest REQUIRED)\ninclude_directories($(GTEST_INCLUDE_DIRS))\ntarget_link_libraries(\u003cprojects-executable-name\u003e $(GTEST_LIBRARIES) pthread)\n```\n\n## Finally running the tests\n\nOnce the executable is built, you can simply run it.\n\n```bash\n./gtest_example\n```\n(if using the provided CMakeLists.txt file)\n\nFor more information about Google Test, check out the official [Google Test Repo](https://github.com/google/googletest).\n\nIf all went well, you should see \n\n```\n\n[PASSED] 2 tests.\n```\n\nAt the bottom.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraleighlittles%2Fminimal-gtest-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraleighlittles%2Fminimal-gtest-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraleighlittles%2Fminimal-gtest-example/lists"}