Skip to main content

Crate caramelo

Crate caramelo 

Source
Expand description

§caramelo

Crates.io downloads crates.io Build Status Crates.io MSRV Documentation MIT licensed codecov

Caramelo (caramel in Portuguese) is a comprehensive, production-ready unit testing framework for Rust with a focus on simplicity and ease of use.

§Features

§Matchers

  • relational: eq, ne, le, lt, ge and gt
  • logical: and, or
  • range: 1..2 or 1.. or ..2 and its variants
  • array: item, len, _in_, each
  • wildcard: any
  • boolean: falsy, truthy
  • string: contains, starts-with, ends-with
  • http: method, path, header, header_value, body
  • json: exact_json_body, partial_json_body
  • xml: exact_xml_body, partial_xml_body
  • others: custom

§Quick Start

Add caramelo to your Cargo.toml:

caramelo = { version = "0.1.0" }

§Feature flags

  • http - Enable HTTP matchers
  • json - Enable JSON matchers
  • xml - Enable XML matchers

§Usage Example

Here’s how simple it is to create unit tests with caramelo:

use caramelo::{expect, matchers::eq};

#[test]
fn test_equal() {
    expect(1).to_be(eq(1));
}

#[test]
#[should_panic(expected = "Expected 1 to be equals to 2")]
fn test_not_equal() {
    expect(1).to_be(eq(2));
}

§License

Licensed under either of

at your option.

§Author

Rogerio Pereira Araujo rogerio.araujo@gmail.com

Modules§

http
Module containing request wrapper
matchers
Module containing matchers for assertions

Macros§

and
Creates an AND matcher that combines multiple matchers
or
Creates an OR matcher that combines multiple matchers

Structs§

Expect
Main expectation struct for assertions
Verify
Main expectation struct for assertions

Enums§

MatchType
Enum representing the type of match operation

Traits§

Matcher
Trait for matchers used in assertions
MatcherExt
Trait for extending matchers with additional methods
TypedMatcher
Trait for matchers that have a specific type

Functions§

expect
Function to create a new expectation
verify
Function to create a new expectation