unit-testing 1.0.2

A unit testing library
Documentation
unit-testing-1.0.2 has been yanked.

Lib unit

To run unit test for your rust applications

Installation

cargo add unit-testing

Configuration file


# Cargo.toml

[package]
name = "<package_name_here>"
version = "0.1.0"
edition = "2021"
description = "<package_description_here>"
license = "GPL-2.0-or-later"
repository = "<repository_url>"
documentation= "https://docs.rs/<package_name>"

[lib]
name = "<your_lib_name>"
path = "src/lib.rs"
crate-type = ["lib"]
test = true             # Is tested by default.
doctest = true          # Documentation examples are tested by default.
bench = true            # Is benchmarked by default.
doc = true              # Is documented by default.
harness = true          # Use libtest harness.

[[bin]]
name = "unit-testing"
path = "src/bin.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
colored_truecolor = "0.1.0"
mockall = "0.11.3"
progress_bar = "1.0.3"
unit-testing = "0.3.3"

Usage


use unit::Tdd;

fn pythagore(t: &mut Tdd) -> &mut Tdd
{
    t.assert
    (
        4 * 4 + 3 * 3 == 5 * 5,
        "The triangle 4 by 3 is rectangle",
        "The triangle 4 by 3 is not rectangle",
    )
        .assert
        (
            8 * 8 + 15 * 15 == 17 * 17,
            "The triangle 8 by 15 is rectangle",
            "The triangle 8 by 15 is not rectangle",
        ).assert
    (
        5 * 5 + 12 * 12 == 13 * 13,
        "The triangle 5 by 12 is rectangle",
        "The triangle 5 by 12 is not rectangle",
    )
}
    Tdd::describe(
        "Check the pythagore theorem",
        &pythagore,
    ).ok().expect("A triangle is not rectangle");
./target/debug/unit-testing

Unit testing output