Crate assertables

source
Expand description

§Assertables: Rust crate of assert macros for testing

The assertables Rust crate provides many assert macros to improve your compile-time tests and run-time reliability.

§Introduction

The Assertables Rust crate provides many assertion testing macros, such as for testing values with assert_gt, results with assert_ok, groups with assert_all, processes with assert_command, and more. See below for details.

Top benefits:

  1. You can write better tests to improve reliability and maintainability.
  2. You can handle more corner cases without needing to write custom code.
  3. You can troubleshoot faster because error messages show specifics.

To use this crate, add it to your file Cargo.toml:

assertables = "9.0.0"

Top features:

  1. Easy to use: everything is well-documented with runnable examples.
  2. Zero overhead: if you don’t use a macro, then it’s never compiled.
  3. More forms: for runtime, for side-by-side, for success return, etc.

Help:

§Highlights

Values:

Approximations:

Groups for iterators, chars, etc.:

Infix for order operators, logic operators, etc.:

Parts for strings, vectors, etc.:

Lengths and counts for strings, vectors, iterators, etc.:

Matching for strings, regex, etc.:

Result Ok & Err:

Option Some & None:

Poll Ready & Pending:

Read file system paths and input/output streams:

Run processes and use stdout or stderr:

Collections for arrays, vectors, iterators, sets, maps:

For a complete list of modules and macros, see the docs

§Forms

All the macros have forms for an optional message:

All the macros have forms for different outcomes:

Many of the macros have forms for comparing one item (to an expression) or two items (to each other):

Many of the macros return more information upon success, in case you want to do further testing or tracing, such as:

  • let inner = assert_ok!(result); //=> result.unwrap()
  • let string = assert_fs_read_to_string_ne!("alfa.txt", ""); //=> file contents
  • let stdout = assert_command_stdout_gt!("ls", vec![b' ']); //=> process handle

§Tracking

  • Package: assertables-rust-crate
  • Version: 9.0.0
  • Created: 2021-03-30T15:47:49Z
  • Updated: 2024-10-23T20:21:04Z
  • License: MIT or Apache-2.0 or GPL-2.0 or GPL-3.0 or contact us for more
  • Contact: Joel Parker Henderson (joel@sixarm.com)

Modules§

Macros§