This wiki is obsolete

This wiki is obsolete. The new version is in the Rust documentation.

Old content

This crate is in alpha state. It is fully usable, but one can (rightfully) think that there are incomplete or missing features. The maintainer would be very happy if he was given some feedback, issues, pull requests, etc.

fluid is a crate to make the tests more readable and easier to write, inspired by xUnit. It is still in an unstable state. Be adviced that in future alphas — let alone in the release — it could/will be very different.

Get started

Do not forget that everything related to this crate must be used only within a test config (i.e., with a #[cfg(test)] attribute). Otherwise, you are mixing your library sources with your tests.

Add the crate in your Cargo.toml:

[dev-dependencies] fluid = "0.3"

Reference the crate in your main file:

#[cfg(test)] extern crate fluid ;

Import the needed content in scope of your test files:

use fluid :: prelude :: * ;

You can then write your tests:

Fact

#[fact] fn cerberus_has_3_heads () { number_of_faces ( "Cerberus" ) .should () .be_equal_to ( 3 ); }

More about facts.

Theory

#[theory] #[case( "Cerberus" , 3 )] #[case( "Hydra" , 7 )] #[case( "Janus" , 2 )] #[case( "Normal guy" , 1 )] fn each_creature_has_a_correct_number_of_faces ( name : & str , nbr_faces : u8 ) { number_of_faces ( name ) .should () .be_equal_to ( nbr_faces ); }

More about theories.

Goals

The current goals are to provide:

[DONE] Easily readable tests: they should be read like english sentences.

Easily readable tests: they should be read like english sentences. [DONE] Nice and understandable error messages.

Nice and understandable error messages. [TODO] The most possible useful assertions for common cases: numbers, Iterators , Options , Results , etc.

The most possible useful assertions for common cases: numbers, , , , etc. [TODO] A full test framework that launches the tests, displays the failures, etc. This will be released only when this feature is stabilized.

Non-goals:

Run the tests fast: under the hood, there are some code generation at compile-time, especially for the #[theory] tests. This will never be as fast as the standard tests.

Known bugs/limitations