racetrack
A library for writing assertions on methods, function and closure calls.
Racetrack allows for tracking direct and indirect calls to methods. It's inspired by Jest's fn()
and spyOn
.
The library consists of the tracker, which handles assertions, as well as a proc-macro that allows for automatic tracking injection into methods.
Usage
The intended usage is with the proc macro.
use ;
;
let tracker = new;
let tracked = TrackedStruct;
tracked.tracked_fn;
tracker
.assert_that
.was_called_once
.with;
However, this has some caviats. All arguments and the return type must implement ToOwned
and
it may not work if you have very specific requirements.
So, alternatively, you can use the tracker manually:
use ;
;
let tracker = new;
let tracked = TrackedStruct;
tracked.tracked_fn;
tracker
.assert_that
.was_called_once
.with;
License: Apache-2.0