Skip to content

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
    • Help
    • Contribute to GitLab
  • Sign in / Register
F
fluid-rs
  • Project
    • Project
    • Details
    • Activity
    • Cycle Analytics
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Charts
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
    • Charts
  • Registry
    • Registry
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Boiethios
  • fluid-rs
  • Wiki
  • Home

Home

Last edited by Boiethios Nov 24, 2018
Page history

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.
  • [DONE] Nice and understandable error messages.
  • [TODO] The most possible useful assertions for common cases: numbers, Iterators, Options, Results, 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

  • Stringification of the left element is not perfect when the procedural macros are used. That is because there is no way to render the token as they were written by the user (as far as I know).

  • For now, a theory stops at the first failed case. Is it a desirable behavior? If not, how to implement that? Maybe with a module with a function per case.

  • Hygiene issue. For now, every span is located at the macro call site.

  • Let the possibility for the users to create their own assertions.

  • Maybe, add some fixture/setup capacities.

Clone repository

Home

List of assertions

Fact

Theory


Changelog

More Pages

New Wiki Page

Tip: You can specify the full path for the new file. We will automatically create any missing directories.