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,
Iterators,Options,Results, etc.
How to use it
Add the crate in your Cargo.toml:
# Do not use in crate build, only in test
[]
= "0.1"
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 my_result: = Err; //Oops
theory!.should.not.be_an_error
.and_should.contain
.because;
Displays:
The test failed at src/tests.rs:76:
'my_result' should not have been an error
But it is: 'Err(())'
'my_result' should have contain '42'
But it does not.
This test should have pass because I must have 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;
Iterators
theory!.should.contain;
theory!.should.not.contain;
theory!.should.not.contain;