Documentation

sweet

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.

Quickstart

  1. edit cargo.toml
    [dev-dependencies]
    sweet = # current version here
    
    [[test]]
    name = "sweet"
    path = "test/sweet.rs"
    harness = false
    
  2. create file test/sweet.rs
    #![feature(imported_main)]
    pub use sweet::*;
    
    sweet! {
    	it "works" {
    		expect(true).to_be_false()?;
    	}
    }
    
  3. run these commands
    rustup default nightly
    cargo test --test sweet
    

Features

  • Nested Tests
    • Sweet is designed to collect and run all tests in one go. All tests exposed in the sweet.rs file will be run:

       //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;
      
  • Pretty success messages
    • success
  • In progress indication
    • progress
  • Failure context
    • failure

Example Commands

  • Run
    • cargo test --test sweet
  • With watch
    • cargo watch -q -x 'test --test sweet -- -w'
    • Clears terminal on each run
    • Returns an exit code zero (cleaner output)
  • Specify filename
    • cargo test --test sweet -- my_test

Reference