Very early stage warning! No ongoing maintenance is guaranteed
Basically a jest clone, the sweet
crate will set you up with a beautiful test harness and intuitive matchers that are easy on the eyes.
```rust pub use sweet::*;
sweet! { it "works" { assert!("regular assertions and panics".len() > 0);
expect("custom matchers").to_contain("custom")?;
} } ```
edit cargo.toml
```toml
[dev-dependencies]
sweet = # current version here
[[test]] name = "sweet" path = "test/sweet.rs" harness = false ```
create file test/sweet.rs
```rust
pub use sweet::*;
sweet! { it "works" { expect(true).tobefalse()?; } } ```
sh
rustup default nightly
cargo test --test sweet
Pretty Messages
Mutable globals
rust
sweet! {
let mut a = 0;
before {
a = a + 1;
}
test "before" {
expect(a).to_be(1)?;
}
}
Automatic suite names
rust
//named after file
sweet!{
it "works"{}
}
//custom name
sweet!{ "My Test"
it "works"{}
}
sweet.rs
file will be run:
rust
//test/sub_dir/some_test.rs
sweet!{
it "works" {
expect(true).to_be_true();
}
}
//test/sub_dir/mod.rs
mod some_test
//test/sweet.rs
#![feature(imported_main)]
pub use sweet::*;
mod sub_dir;
cargo test --test sweet
cargo watch -q -x 'test --test sweet -- -w'
cargo test --test sweet -- my_test