{"repo":"bytedance/mockey","free":true,"listed":false,"github":"https://github.com/bytedance/mockey","clone":"git clone https://github.com/bytedance/mockey.git","description":"A simple and easy-to-use Go mocking library derived from ByteDance's internal best practices","language":"Go","stars":903,"topics":["golang","mock","test","testing"],"license":"Apache-2.0","category":"dev-tools","readme_excerpt":"Mockey English 中文 Mockey is a simple and easy-to-use golang mock library, which can quickly and conveniently mock functions and variables. At present, it is widely used in the unit test writing of ByteDance services (7k+ repos) and is actively maintained. In essence, it rewrites function instructions at runtime similarly to monkey or gomonkey. Mockey makes it easy to replace functions, methods and variables with mocks reducing the need to specify all dependencies as interfaces. 1. Mockey requires inlining and compilation optimization to be disabled during compilation, or it won't work. See the FAQs for details. 2. It is strongly recommended to use it together with the goconvey library in unit tests. Install Quick Guide Simplest example Unit test example Features - Mock functions and methods - Basic - Simple / generic / variadic function or method (value or pointer receiver) - Supporting hook function - Supporting PatchConvey and PatchRun (automatically release mocks after each test case) - Providing GetMethod to handle special cases (e.g., unexported types, unexported method, and methods in nested structs) - Advanced - Interface mocking (experimental feature) - Conditional mocking - Sequence returning - Decorator pattern (execute the original function after mocking) - Goroutine filtering (inclusion, exclusion, targeting) - Acquire Mocker for advanced usage (e.g., getting the execution times of target/mock function) - Mock variable - Common variable - Function variable Compati","default_branch":null,"files":null,"tree":[],"storefront":"/r/bytedance","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/bytedance/mockey/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}