Fluid
Summary
fluid
is an human readable test library.
The current goals of this crate are:
- Easily readable tests: they should be read like english sentences.
- Nice and understandable error messages.
- Provide the most possible useful assertions for common cases:
numbers,
Iterator
s,Option
s,Result
s, etc.
How to use it
Add the crate in your Cargo.toml
:
# Do not use in crate build, only in test
[]
= "0.2"
Reference the crate in your main file:
extern crate fluid;
Import the crate content in scope of your tests file:
use *;
Examples
Simple equality
theory!.should.be_equal_to;
Negation
theory!.should.not.be_equal_to;
Explanation
theory!.should.be_equal_to
.because;
Nice error message
let the_answer: = Err;
theory!.should.not.be_an_error
.and_should.contain
.because;
Displays:
The test failed at src/tests/message.rs:16:
the_answer should not have been an error
but it is: Err("Oops, error!").
the_answer does not contain 42: Err("Oops, error!")
but it should.
This test should pass because we need the answer.
Floats precision
theory!.should.be_equal_to.with_precision;
Result::Err
let parse_error = match "?". ;
let result = "two".;
theory!.should.be_an_error
.and_should.be_this_error;
Iterator
s
theory!.should.contain;
theory!.should.not.contain;
theory!.should.not.contain;