{"id":16679667,"url":"https://github.com/mrk21/bandit_with_gmock","last_synced_at":"2026-05-28T19:02:27.547Z","repository":{"id":9951021,"uuid":"11970353","full_name":"mrk21/bandit_with_gmock","owner":"mrk21","description":"This library is for using GoogleMock by Bandit.","archived":false,"fork":false,"pushed_at":"2015-01-18T11:33:50.000Z","size":244,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-26T08:35:56.743Z","etag":null,"topics":["bandit","cpp","cpp11","googlemock"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrk21.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":"2013-08-08T07:16:23.000Z","updated_at":"2017-07-20T09:48:16.000Z","dependencies_parsed_at":"2022-08-19T06:21:54.890Z","dependency_job_id":null,"html_url":"https://github.com/mrk21/bandit_with_gmock","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/mrk21/bandit_with_gmock","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbandit_with_gmock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbandit_with_gmock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbandit_with_gmock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbandit_with_gmock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrk21","download_url":"https://codeload.github.com/mrk21/bandit_with_gmock/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrk21%2Fbandit_with_gmock/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33622070,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-28T02:00:06.440Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["bandit","cpp","cpp11","googlemock"],"created_at":"2024-10-12T13:36:45.963Z","updated_at":"2026-05-28T19:02:27.527Z","avatar_url":"https://github.com/mrk21.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"bandit_with_gmock\n=================\n\nThis library is for using [GoogleMock](https://code.google.com/p/googlemock \"GoogleMock\") by [Bandit](https://github.com/joakimkarlsson/bandit \"Bandit\"). \n\n## Examples\n\n```c++\n#include \u003cbandit_with_gmock/bandit_with_gmock.hpp\u003e\n\nclass hoge {\npublic:\n    void func(bool is_call_func1){\n        this-\u003efunc1();\n        this-\u003efunc2();\n    }\n    virtual void func1(void) = 0;\n    virtual void func2(void) = 0;\n};\n\nclass hoge_mock: public hoge {\npublic:\n    MOCK_METHOD0(func1, void(void));\n    MOCK_METHOD0(func2, void(void));\n};\n\ngo_bandit([]{\n    using namespace bandit;\n    \n    // describe hoge\n    // \tdescribe #func(bool is_call_func1)\n    // \t\tdescribe when `is_call_func1` was false\n    // \t\t\t- it should not call `#func1()` ... FAILED\n    // \t\tdescribe when `is_call_func1` was true\n    // \t\t\t- it should call `#func1()` ... OK\n    // \n    // There were failures!\n    // \n    // hoge #func(bool is_call_func1) when `is_call_func1` was false should not call `#func1()`:\n    // src/main.cpp:40: Mock function called more times than expected - returning directly.\n    //     Function call: func1()\n    //          Expected: to be never called\n    //            Actual: called once - over-saturated and active\n    // \n    // Test run complete. 2 tests run. 1 succeeded. 1 failed.\n    describe(\"hoge\", [\u0026]{\n        describe(\"#func(bool is_call_func1)\", [\u0026]{\n            describe(\"when `is_call_func1` was false\", [\u0026]{\n                it(\"should not call `#func1()`\", [\u0026]{\n                    hoge_mock hoge;\n                    EXPECT_CALL(hoge, func1()).Times(0);\n                    EXPECT_CALL(hoge, func2()).Times(1);\n                    hoge.func(false);\n                });\n            });\n            \n            describe(\"when `is_call_func1` was true\", [\u0026]{\n                it(\"should call `#func1()`\", [\u0026]{\n                    hoge_mock hoge;\n                    EXPECT_CALL(hoge, func1()).Times(1);\n                    EXPECT_CALL(hoge, func2()).Times(1);\n                    hoge.func(true);\n                });\n            });\n        });\n    });\n});\n\nint main(int argc, char * argv[]) {\n    return bandit_with_gmock::run(argc, argv);\n}\n```\n\n## Dependencies\n\n* [GoogleMock](https://code.google.com/p/googlemock \"GoogleMock\") (ver. 1.7.0)\n* [Bandit](https://github.com/joakimkarlsson/bandit \"Bandit\") (ver. 1.1.4)\n\n## Installation\n\nThis library is header-only, so you don't need to build. You should do the steps listed below to install:\n\n### Manual Installation\n\nYou should set with the compile options listed below to install manually:\n\n#### Include path\n\n* -I path/to/googlemock/include\n* -I path/to/googlemock/gtest/include\n* -I path/to/bandit\n* -I path/to/bandit\\_with\\_gmock\n\n#### Library path\n\n* -L path/to/googlemock\n* -L path/to/googlemock/gtest\n\n#### Library\n\n* -lgmock\n* -lgtest\n\n### Using CMake\n\nIf you used CMake, the compile options will be set automatically by writing the content listed below to your project's CMake scripts:\n\nFirst, you write the content as shown below to the CMake script `CMakeLists.txt` of root directory:\n\n```cmake\ncmake_minimum_required(VERSION 3.0.2)\n\nmessage(\"Building external...\")\ntry_compile(external_status\n  ${PROJECT_BINARY_DIR}/external\n  ${PROJECT_SOURCE_DIR}/external\n  external\n  OUTPUT_VARIABLE external_result\n)\nif(NOT external_status)\n  message(\"${external_result}\")\nendif()\nmessage(\"Built external\")\ninclude(${PROJECT_BINARY_DIR}/external/bandit_with_gmock/lib/cmake/bandit_with_gmock.cmake)\n\nlink_directories(${PROJECT_BINARY_DIR}/external/bandit_with_gmock/lib)\n\nadd_compile_options(-std=c++11)\nadd_executable(test test.cpp)\ntarget_link_libraries(test bandit_with_gmock::core)\n```\n\nNext, you create `external` directory, and write the content shown below to CMake script `CMakeLists.txt`:\n\n```cmake\ncmake_minimum_required(VERSION 3.0.2)\n\ninclude(ExternalProject)\n\nExternalProject_Add(bandit_with_gmock\n  GIT_REPOSITORY https://github.com/mrk21/bandit_with_gmock.git\n  GIT_TAG v1.2.0\n  PREFIX bandit_with_gmock\n  CMAKE_ARGS\n    -DCMAKE_INSTALL_PREFIX=\u003cINSTALL_DIR\u003e\n    -DBUILD_DEPENDENCY=ON\n)\n```\n\nIn addition, if you specified `bandit_with_gmock::main` instead of `bandit_with_gmock::core` to `target_link_libraries()` command, you will not need to write the main function to your test code `test.cpp`. In this case, you should specify `-DBUILD_LIBRARY` CMake option.\n\n`CMakeLists.txt`:\n\n```cmake\n...\ntarget_link_libraries(test bandit_with_gmock::main)\n```\n\n`external/CMakeLists.txt`:\n\n```cmake\n...\nExternalProject_Add(bandit_with_gmock\n  GIT_REPOSITORY https://github.com/mrk21/bandit_with_gmock.git\n  GIT_TAG v1.2.0\n  PREFIX bandit_with_gmock\n  CMAKE_ARGS\n    -DCMAKE_INSTALL_PREFIX=\u003cINSTALL_DIR\u003e\n    -DBUILD_DEPENDENCY=ON\n    -DBUILD_LIBRARY=ON\n)\n```\n\n## Command line options\n\nCan use GoogleMock and Bandit options.\n\n## Other stuff\n\n* [BDD gmock Aliases](https://github.com/andystanton/gmock-bdd-aliases).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrk21%2Fbandit_with_gmock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrk21%2Fbandit_with_gmock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrk21%2Fbandit_with_gmock/lists"}