Skip to content

Commit 28ac4e0

Browse files
committed
in the README, show usage as a dev-dependency
Fixes #98
1 parent 459ed5c commit 28ac4e0

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,25 @@ mockall = "0.6.0"
3535
Then use it like this:
3636

3737
```rust
38-
use mockall::*;
39-
use mockall::predicate::*;
40-
#[automock]
38+
#[cfg(test)]
39+
use mockall::{automock, mock, predicate::*};
40+
#[cfg_attr(test, automock)]
4141
trait MyTrait {
4242
fn foo(&self, x: u32) -> u32;
4343
}
4444

45-
let mut mock = MockMyTrait::new();
46-
mock.expect_foo()
47-
.with(eq(4))
48-
.times(1)
49-
.returning(|x| x + 1);
50-
assert_eq!(5, mock.foo(4));
45+
#[cfg(test)]
46+
mod tests {
47+
#[test]
48+
fn mytest() {
49+
let mut mock = MockMyTrait::new();
50+
mock.expect_foo()
51+
.with(eq(4))
52+
.times(1)
53+
.returning(|x| x + 1);
54+
assert_eq!(5, mock.foo(4));
55+
}
56+
}
5157
```
5258

5359
See the [API docs](https://docs.rs/mockall) for more information.

0 commit comments

Comments
 (0)