NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
crates.io · #604 most downloaded on crates.io
Procedural macros for Mockall
Last release 3 months ago
28 Jun 2026
Ships fairly regularly
a new release about every 5 months
Nearly every release is documented
notes for 31 of 32 stable releases
Nothing withdrawn
no release was ever pulled
7 years old
33 releases · first in 2019
chore: Release mockall version 0.15.0
chore: Release mockall version 0.15.0
chore: Release mockall version 0.14.0
chore: Release mockall version 0.14.0
Allow mocking structs and traits with const generics. (#649)
Compatibility with the #[trait_variant::make] macro.
(#640)
Allow Expectations with a non-exact call count to be used in Sequences. (#660)
No longer poison a static mock method's internal Mutex when panicing, even
when using a stable Rust compiler. Also, no longer poison it even if there
is no Context object. For example, if the user never set an Expectation at
all.
(#650)
Suppress single-use-lifetimes lints in the generated code, for cases where
the orginal code wouldn't have triggered the warning.
(#627)
Fix mocking foreign functions with a variadic argument and no pattern, for
example fn foo(...) as opposed to fn bar(x: ...). That worked in prior
versions of Mockall only until Rust 1.93.0, which made such arguments illegal
for Rust functions.
(#673)
Fully qualify Send and Sync traits in generated code, allowing structs named
Send or Sync to be in scope without conflicts.
(#672)
One column per quarter.
chore: Release mockall version 0.13.1
chore: Release mockall version 0.13.1
Suppress warnings about the #[expect] lint, new in Rust 1.81.0, in
generated code.
(#619)
Suppress the #[clippy::ref_option] warning, new in Rust 1.83.0, in
generated code.
(#618)
When mocking functions with a closure argument, but not using
#[concretize], include any additional trait bounds in the trait object
argument passed to .with and .returning.
(#606)
Fixed naming conflict when mocking multiple traits with same name but from different modules. (#601)
Add the ability to use #[concretize] with methods that have an FnMut argument.
Add the ability to use #[concretize] with methods that have an FnMut
argument.
(#595)
Add the ability to mock methods that use #[auto_enum], from the
auto_enums crate. But only for methods that use RPIT; Mockall can't yet
handle syntax like -> Result<(), impl T>
(#590)
Add the ability to mock methods that use #[inline] or #[cold], and
methods or traits that use #[must_use].
(#555)
Raised MSRV to 1.71.0 due to the C-unwind ABI.
(#585)
No longer poison a Context object's internal Mutex when panicing. This
requires the "nightly" feature.
(#527)
extern "C" functions, for example due to
unsatisfied expectations, with Rust 1.81.0 or newer.
(#585)chore: Release mockall version 0.12.1
chore: Release mockall version 0.12.0
chore: Release mockall version 0.12.0
Added #[mockall::concretize], which can be used to mock some generic
methods that have non-'static generic parameters. It works by turning the
generic arguments into trait objects for the expectation.
(#408)
When mocking functions with a non-default ABI (Like extern "C"), the mock
function will now use the same ABI as the original. Name mangling will also
be disabled, so the mock function will be callable from external code. For
example, from C functions.
(#504)
Raised predicates, which is reexported, to 3.0.0. This may affect backwards compatibility for users who make use of predicates's "color" feature. (#467)
Raised MSRV to 1.64.0 because predicates-core and predicates-tree did. (#430) (#467)
Better "No matching expectation found" messages on stable. (#425)
Fixed mocking non-private inherent methods that have attributes with syn version 2.0.9 and later. (#486)
Suppress clippy::too_many_arguments warnings in the generated code. This
is most useful when mocking static functions with exactly 7 arguments.
(#487)
Fixed unused_attributes warnings in the generated code when mocking FFI
functions that use #[link_name].
(#503)
Fix a panic during Drop for static methods. One way to trigger it is by
calling the method more times than is allowed by a .times() constraint.
Another way would be to explicitly panic during the .returning method.
(#516)
(cargo-release) mockall version 0.11.4
(cargo-release) mockall version 0.11.3
(cargo-release) mockall version 0.11.3
where Self: ... clause will now be mocked like concrete
methods, not generic ones. Among other effects, this prevents "unused method
expect" warnings from the latest nightly compiler.
(#415)(cargo-release) mockall version 0.11.2
Fixed mocking methods that use Self in their arguments, but not as the receiver. For example, PartialEq::eq has a signature like fn eq(&self, other: &
Self in their arguments, but not as the
receiver. For example, PartialEq::eq has a signature like
fn eq(&self, other: &Self) -> bool
(#373)dyn T trait object,
when that trait is not already implemented for Box<dyn T>.
(#380)mock! and #[automock] now support unsafe traits.
mock! and #[automock] now support unsafe traits.
(#313)predicates to v2.0.1, see all v2 changes in
predicates' changelog.
(#325)Fix mocking specializing methods of non-generic structs, a regression in v0.10.0.
Fix mocking trait methods whose return values have lifetime parameters, a regression in v0.10.0.
mock! will now allow both methods and trait impls to be gated with #[cfg()]] attributes. The attributes will be forwarded to all generated code. This
mock! will now allow both methods and trait impls to be gated with
#[cfg()]] attributes. The attributes will be forwarded to all generated
code. This allows for example only mocking certain traits on certain OSes.
(#297)
automock will now automatically generate Debug implementations for traits and
structs. mock! will to, if you put #[derive(Debug)] above the struct's
name.
(#289)
Added support for specific impls. A specific impl is an implementation of a
trait on a generic struct with specified generic parameters. For example,
impl Foo for Bar<i32> as opposed to impl<T> Foo for Bar<T>. Mockall does
not yet support generic methods in such traits.
(#274)
mock!{
MyStruct<T: Bounds> {...}
impl Foo for MyStruct {...}
}
should now be written asmock!{
MyStruct<T: Bounds> {...}
impl<T: Bounds> Foo for MyStruct<T> {...}
}
(#274)When a test fails because of a method sequence violation, the error message will now show the method's arguments. This requires the nightly feature, a
When a test fails because of a method sequence violation, the error message
will now show the method's arguments. This requires the nightly feature,
and requires that the arguments implement Debug.
(#247)
When a test fails because a mock object receives an unexpected call, the
error message will now show the method's arguments. This requires the
nightly feature, and requires that the arguments implement Debug.
(#246)
Fixed Clippy warnings in generated code with Rustc 1.52.0. (#255)
Fixed using #[automock] with #[tracing::instrument]. The mock function
won't be instrumented, but at least it will compile.
(#256)
…and #[automock] that module. The old method is deprecated.
Added the ability to mock methods returning impl Future or impl Stream.
Unlike other traits, these two aren't very useful in a Box. Instead,
Mockall will now change the Expectation's return type to Pin<Box<_>>.
(#229)
Added the ability to mock methods returning references to trait objects. (#213)
mock! supports a new syntax: "impl Trait for". It has two benefits:
mock! {
Bar {}
impl Foo<i32> for Bar {
fn foo(&self, x: i32) -> i32;
}
}
(#205)
#[automock] now works on modules even without the nightly feature, and no
longer requires #[feature(proc_macro_hygiene)].
(#198)
mock! now requires visibility specifiers for inherent methods.
(#207)
Changed the syntax for mocking foreign functions. Instead of using
#[automock] directly on the extern block, you must wrap the extern
block in a module, and #[automock] that module. The old method is
deprecated.
(#201)
Fixed mocking methods that return Self inside of a trait object with
multiple bounds. For example: -> impl Future<Output=Self> + Send
(3400916)
Fixed setting multiple expectations on generic methods whose only generic type is the return. (#238)
Fixed mocking generic structs with generic methods whose only generic types
are lifetimes. This is useful for mocking generic structs that implement
traits like Future and Stream.
(#225)
(#226)
(#228)
times_any and times_range methods from Expectations. They've
been deprecated since 0.3.0.
(#197)Suppressed default_trait_access pedantic Clippy lint in generated code
Fixed Clippy warnings for mocked methods with Vec or String arguments.
Fixed using ::Z syntax in a where clause or a return type.
<X as Y>::Z syntax in a where clause or a return type.
(#208)Added support for mocking structs and traits with associated constants.
Added support for mocking structs and traits with associated constants. (#187)
Methods returning slices can now be mocked. Their expectations take Vecs.
(#185)
Compatibility with the #[async_trait] macro.
(#183)
Better support for non-Send types:
return_const_st for returning non-Send constants, similar to
returning_st.return_once_st for static methods. It was already available for
non-static methods.
(#178)Support mocking methods with arbitrary receivers like self: Box<Self>
(#176)
Support mocking methods with trait object arguments that use implicit lifetimes. (#174)
Raised the minimum supported Rust version (MSRV) to 1.42.0. (#175)
Mocked modules now have the same visibility as the original module. (#169)
Fixed mocking modules including functions that use "impl Trait" or mutable arguments. (#169)
Fixed mocking methods whose generic types include super::.
(#167)
Fixed mocking generic methods with where clauses returning references. (#166)
Fixed mocking generic methods returning mutable references. (#165)
Suppressed incomplete_features warnings in the latest nightly.
(#161)
Fixed handling function attributes. They already worked on methods, but not foreign functions or module functions.
Fixed handling function attributes. They already worked on methods, but not foreign functions or module functions. (#129)
Propagate doc comments for module functions to the generated mock functions. (#132)
Fix the formatting of generated doc comments for context methods (#132)
Fixed some visibility issues in the generated mocks for modules and extern functions. (#133)
Fixed mocking methods with complicated types including a super:: component.
(#137)
Mocked generic static methods can now use return_const. This capability
was omitted as an oversight from PR #47.
(#141)
Suppressed unused unit warnings from Clippy in the latest nightly.
(#148)
Fixed unused must_use warnings in consumers' crates on the latest nightly
mock! now allows doc comments in any position
mock! now allows doc comments in any position
(#102)
Added the ability to match non-Send arguments with withf_st
(#93)
Added the ability to mock non-'static structs (but not their constructor
methods)
(#114)
Fixed the docs for mockall_examples
(#103)
Fixed the build with nightly compilers 2020-03-11 and later. This also raises the MSRV to 1.36.0. (#108)
The proc macros will now build successfully in crates that set
#![deny(missing_docs)]
(#107)
Fixed mocking methods with an explicit receiver lifetime like &'a self
(#112)
Added the ability to mock generic methods whose return values' lifetimes are chosen by the caller. Especially useful with std::Future
std::future::Future
(#86)Fixed using prediate::always and prediate::never with ?Sized types
(#80)
Fixed mocking methods when a custom Result type is in-scope.
(#74)
Mock objects' checkpoint methods will no longer check static expectations. This behavior is more useful where static and regular methods are both used
Fixed using super:: in the signature of a bare function
Many generic methods with lifetime parameters can now be mocked. The condition is that they may not also have generic type parameters, and their retur
Many generic methods with lifetime parameters can now be mocked. The
condition is that they may not also have generic type parameters, and their
return values must be 'static.
(#48)
Reexport more traits from the predicates crate (09746e9)
return_const now works for static methods with no preceding with or
withf.
(#47)Warnings for misued expectations and context objects
Warnings for misued expectations and context objects (#37)
Methods with closure arguments and where clauses can now be mocked. (#35)
Mocked static methods and free functions now use a Context object to manage their expectations. The context object will validate call counts when it drops, and clean up any leftover expectations. This makes it practical to use mocked free functions from multiple test cases. The user still will most likely need to provide his own synchronization to prevent such test cases from running concurrently. (#34)
Fixed mocking methods that return 'static deref types, like &'static str
(#39)
Methods returning non-'static references (mutable or otherwise) will now
return a default value if no return value is set, if the output type
implements Default and the nightly feature is enabled. This more closely
matches existing behavior for methods returning non-reference types.
(#32)
The times method now accepts ranges as arguments. types_any and times_range are deprecated.
withf or returning. No special tricks are required by the user.
Similarly, methods with bare fn arguments can be mocked, too.
(#15)It is no longer necessary for consuming crates to explicitly depend on fragile, downcast, or predicates-tree. Mockall now reexports them. (#29)
The MSRV is now Rust 1.35.0 (#15)
The times method now accepts ranges as arguments. types_any and
times_range are deprecated.
(#14)
Fixed mocking methods with arguments or return values that use Self as an
associated type of some other trait.
(#28)
Fixed mocking structs and traits with more than one static method. (#22)
Methods of generic structs and traits that reference Self (such as
constructors or comparators) can now be mocked without any hacks.
(#21)
(#25)
Specializing methods of generic structs (and traits) can now be mocked without the hack of duplicating the struct's (or trait's) generic parameters. (#20)
Static methods of generic structs (and traits) can now be mocked without the hack of duplicating the struct's (or trait's) generic parameters. (#19)
Fixed some hygiene problems introduced in 0.2.0
Support mocking generic specializing methods.
Support mocking generic specializing methods. (#13)
Correctly handle where clauses on mocked methods. (#13)
Allow mocking generic constructor methods (#11)
Allow mocking methods that use super somewhere in their signatures.
(#8)
Fixed #[automock] for new methods with arguments.
(#3)
Fixed the never method, which never actually worked.
(#10)
Fixed mocking generic traits or structs with generic methods (6126359)
Fixed an issue with using associated types in generic parameter bounds (116e5a2)
Fixed mocking methods with mutable arguments (8058701)
expectation!, used to manually mock methods in rare circumstances.
Now mock! and #[automock] are the only way to use Mockall.
(#12)Nothing published for this version
Nothing published for this version
Your coding agent can read these notes before it upgrades. Set up the MCP server →