shoulds 0.2.0

An intuitive and simple library for writing test assertions in a natural and fluent language.
Documentation

shoulds

shoulds is a fluent assertion library for Rust tests, inspired by FluentAssertions and Shouldly.

It helps you write readable, intention-revealing tests like:

use shoulds::Shouldable;

let result = 42;
result.should().eq( & 42);

โœจ Assertions

Currently supported:

โœ… Equality

  • should().eq(&expected)
  • should().ne(&unexpected)

More comparison methods (greater than, less than, etc.) are coming soon.


๐Ÿ“ฆ Installation

In your Cargo.toml:

[dev-dependencies]
shoulds = "0.2.0"

๐Ÿงช Example

use shoulds::Shouldable;

fn add(a: i32, b: i32) -> i32 {
    a + b
}

#[test]
fn it_adds_numbers() {
    let result = add(40, 2);
    result.should().eq(&42);
}

๐Ÿšง Roadmap

Planned enhancements include:

  • String and collection assertions (contain, have_length, etc.)
  • Result/Option assertions (be_ok, be_some)
  • Custom diffing for better failure output
  • Optional colored output
  • Snapshot support?

Want to help shape this crate? Feedback and contributions welcome!


โš ๏ธ Note

shoulds is still experimental and evolving. Expect breaking changes in the 0.x versions.


๐Ÿ“„ License

MIT