https://github.com/peterpaul/assert4rs
Fluent assertions for Rust.
https://github.com/peterpaul/assert4rs
assertions testing tests unittests
Last synced: 5 months ago
JSON representation
Fluent assertions for Rust.
- Host: GitHub
- URL: https://github.com/peterpaul/assert4rs
- Owner: peterpaul
- License: mit
- Created: 2020-12-17T20:32:08.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2025-01-09T17:55:04.000Z (over 1 year ago)
- Last Synced: 2025-09-22T14:33:27.682Z (10 months ago)
- Topics: assertions, testing, tests, unittests
- Language: Rust
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# assert4rs
A fluent assertion library for Rust. Write expressive, chainable test assertions that read like natural language.
```rust
use assert4rs::Assert;
Assert::that(vec![1, 2, 3])
.contains(&2)
.has_length(3);
Assert::that(String::from("hello world"))
.starts_with("hello")
.ends_with("world");
Assert::that(Some(42))
.unwrap()
.is_gt(0)
.satisfies(|v| v % 2 == 0);
```
## Usage
Add to your `Cargo.toml`:
```toml
[dev-dependencies]
assert4rs = "0.2"
```
All assertions start with `Assert::that(value)` and can be chained fluently:
```rust
use assert4rs::Assert;
Assert::that("foo")
.is("foo")
.is_not("bar");
```
No trait imports needed — everything works through `Assert` alone.
## License
MIT