Write many tests quickly and cleanly.
```rust pub use sweet::*;
sweet! { it "works" { // use regular assertions assert!(true == false); // or pretty matchers expect(true).tobefalse()?; expect("some string").not().tostartwith("some")?; } } ```
The Sweet harness has a couple of advantages over default tests.
- Suites - Organize your tests into collections
- Matchers - Matchers specific to a type enables a harness to output more intuitive results instead of an opaque panic!
- rs
expect("foo").not().to_start_with("bar")
//expected: NOT to start with 'bar'
//received: 'foo'
- Single Binary - The default intergration test approach creates a seperate binary for each test, which ramps up compile times, see this blog for more info.
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()?; } } ```
cargo test --test sweet
cargo test --test sweet
cargo watch -q -x 'test --test sweet -- -w'
cargo test --test sweet -- my_test
/
to specify directories
cargo test --test sweet -- my_dir/my_test
The wasm test harness has different priorities from wasm-bindgen-test - UI - Tests are run in a *mostly isolated iframe (see TODO) - Interactive - the runner will list all tests and they can be run at-will in the browser.
cargo install forky_cli
forky_cli sweet
forky_cli sweet -p my_package
Or do, thats ok too. Currently you'll get the prettiest output by using the provided matchers that return results intstead of panicing, especially in wasm as panic=unwind
isnt yet supported for wasm.