Registry / testing / mockall

mockall

JSON →
library0.14.0rscratesunverified

A powerful mock object library for Rust, enabling easy creation of mock structs and traits for testing.

# Cargo.toml [dependencies] mockall = "0.14.0"
INSTALL
IMPORT
SIG · MOCKALL
M
mockall
testingrustv0.14.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

automock
use mockall::automock;

Define a mock trait using `#[automock]` and set expectations.

use mockall::automock; #[automock] pub trait MyTrait { fn do_something(&self) -> i32; } let mock = MockMyTrait::new(); mock.expect_do_something().returning(|| 42); assert_eq!(mock.do_something(), 42);
Debug
Known issues
gotchaMockall generates code that may conflict with other derive macros; order of attributes matters.
fix
Place `#[automock]` before other derive macros like `#[derive(Debug)]`.
affects: >=0.14.0
Upgrade
Version history
0.14.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
3 hits · last 30 days
node
2
Amazon
1
Resources
mockall — cargo add mockall · libregistry