shoulds

Crates.ioshoulds
lib.rsshoulds
version0.3.0
created_at2021-12-12 16:25:11.777722+00
updated_at2025-07-13 15:50:19.717599+00
descriptionAn intuitive, fluent assertion library for writing expressive test expectations in Rust.
homepage
repositoryhttps://github.com/tarrball/shoulds
max_upload_size
id496617
size25,894
Andrew Tarr (tarrball)

documentation

README

shoulds

Crates.io

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;

#[test]
fn adds_numbers_correctly() {
    let result = 40 + 2;

    result.should().eq(&42);
}

The API is designed to be intuitive and discoverable, so you can express expectations naturally—with minimal boilerplate and maximum clarity.


✨ Assertions

Currently supported:

🔢 Equality

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

✅ Booleans

  • should().be_true()
  • should().be_false()

🧩 Option

  • should().be_some()
  • should().be_none()

🧪 Result

  • should().be_ok()
  • should().be_err()

📦 Installation

In your Cargo.toml:

[dev-dependencies]
shoulds = "0.3.0"

🧪 Examples

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);
}

📄 License

MIT

Commit count: 26

cargo fmt