{"id":13478634,"url":"https://github.com/asomers/mockall","last_synced_at":"2025-05-11T03:46:28.876Z","repository":{"id":40449560,"uuid":"169656159","full_name":"asomers/mockall","owner":"asomers","description":"A powerful mock object library for Rust","archived":false,"fork":false,"pushed_at":"2025-04-29T17:16:44.000Z","size":1365,"stargazers_count":1632,"open_issues_count":40,"forks_count":71,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-08T01:00:03.667Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/asomers.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-02-07T22:59:28.000Z","updated_at":"2025-05-06T16:01:42.000Z","dependencies_parsed_at":"2023-09-22T05:41:06.103Z","dependency_job_id":"ca0c77c4-8e34-4102-8970-f5a42471ffce","html_url":"https://github.com/asomers/mockall","commit_stats":{"total_commits":889,"total_committers":32,"mean_commits":27.78125,"dds":"0.055118110236220486","last_synced_commit":"2e931ad3c1d841c3822ba065d7a16909b30edd6c"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asomers%2Fmockall","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asomers%2Fmockall/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asomers%2Fmockall/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asomers%2Fmockall/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asomers","download_url":"https://codeload.github.com/asomers/mockall/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252978754,"owners_count":21834915,"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":[],"created_at":"2024-07-31T16:01:59.672Z","updated_at":"2025-05-08T01:00:28.661Z","avatar_url":"https://github.com/asomers.png","language":"Rust","readme":"# Mockall\n\nA powerful mock object library for Rust.\n\n[![Build Status](https://api.cirrus-ci.com/github/asomers/mockall.svg)](https://cirrus-ci.com/github/asomers/mockall)\n[![Crates.io](https://img.shields.io/crates/v/mockall.svg)](https://crates.io/crates/mockall)\n[![Documentation](https://docs.rs/mockall/badge.svg)](https://docs.rs/mockall)\n\n## Overview\n\nMock objects are a powerful technique for unit testing software.  A mock object\nis an object with the same interface as a real object, but whose responses are\nall manually controlled by test code.  They can be used to test the upper and\nmiddle layers of an application without instantiating the lower ones, or to\ninject edge and error cases that would be difficult or impossible to create\nwhen using the full stack.\n\nStatically typed languages are inherently more difficult to\nmock than dynamically typed languages. Since Rust is a statically typed language, \nprevious attempts at creating a mock object library have had mixed results. Mockall \nincorporates the best elements of previous designs, resulting in it having a rich \nfeature set with a terse and ergonomic interface. Mockall is written in 100% *safe* \nand *stable* Rust.\n\n## Usage\n\nTypically mockall is only used by unit tests.  To use it this way, add this to\nyour `Cargo.toml`:\n\n```toml\n[dev-dependencies]\nmockall = \"0.13.1\"\n```\n\nThen use it like this:\n\n```rust\n#[cfg(test)]\nuse mockall::{automock, mock, predicate::*};\n#[cfg_attr(test, automock)]\ntrait MyTrait {\n    fn foo(\u0026self, x: u32) -\u003e u32;\n}\n\n#[cfg(test)]\nmod tests {\n    use super::*;\n\n    #[test]\n    fn mytest() {\n        let mut mock = MockMyTrait::new();\n        mock.expect_foo()\n            .with(eq(4))\n            .times(1)\n            .returning(|x| x + 1);\n        assert_eq!(5, mock.foo(4));\n    }\n}\n```\n\nSee the [API docs](https://docs.rs/mockall) for more information.\n\n# Minimum Supported Rust Version (MSRV)\n\nMockall is supported on Rust 1.77.0 and higher.  Mockall's MSRV will not be\nchanged in the future without bumping the major or minor version.\n\n# License\n\n`mockall` is primarily distributed under the terms of both the MIT license\nand the Apache License (Version 2.0).\n\nSee LICENSE-APACHE, and LICENSE-MIT for details\n\n# Acknowledgements\n\nMockall was not built in a day.  JMock was probably the first popular mock\nobject library.  Many ports and imitations have been made, including GoogleMock\nfor C++.  Mockers, inspired by GoogleMock, was the first attempt to bring the\nconcept to Rust.  The now-defunct Mock_derive was the first library to generate\nmock objects with procedural macros, greatly reducing the user's workload.\nMockall also uses proc macros, and copies many of Mockers' features and\nconventions.  Mockall also takes inspiration from Simulacrum's internal design,\nand its technique for mocking generic methods.\n","funding_links":[],"categories":["Rust","Development tools","开发工具 Development tools","虚拟化"],"sub_categories":["Testing","测试 Testing","测试框架"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasomers%2Fmockall","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasomers%2Fmockall","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasomers%2Fmockall/lists"}