master | 0.4.0 |
---|---|
Mockers
Mocking library for Rust.
Inspired by Google Mock library for C++.
Limitations
For now it is not a full-featured mocking library, but just a prototype to gather feedback. For example, only methods with four or less arguments are supported, non-'static lifetimes are not supported and so on.
Mocking magic is implemented using compiler plugin, so nightly Rust is required. It was tested to work with 1.10.0-nightly (8da2bcac5 2016-04-28).
Usage at a glance
This is a very short introduction to show what is possible and how it looks. Read User Guide for details.
Use nightly Rust:
Cargo.toml:
[]
= "0.4.0"
[]
= "0.4.0"
src/lib.rs:
extern crate mockers;
Run tests:
$ cargo test
Compiling air v0.1.0 (file:///Users/kriomant/Temp/air)
Running target/debug/air-b2c5f8b6920cb30a
running 1 test
test test::test_set_temperature_20 ... FAILED
failures:
---- test::test_set_temperature_20 stdout ----
thread 'test::test_set_temperature_20' panicked at '
error: unexpected call to `AirConditioner#0.make_hotter(36)`
note: here are active expectations for AirConditioner#0.make_hotter
expectation `AirConditioner#0.make_hotter(4)`:
arg #0: 36 is not equal to 4
'
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
test::test_set_temperature_20
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
error: test failed
License
Copyright © 2016 Mikhail Trishchenkov
Distributed under the MIT License.