qutonium 0.1.1

simplify unit testing with a functional testing framework
Documentation

qutonium


simplify unit testing with a minimal testing framework

DISCLAIMER

qutonium is takes is inspiration from the rust-testing-microframework. the goal is to provide a minimal testing framework for assertions (see the list of features here). the project is still in work in progress so.. DO NOT USE IN PRODUCTION. DO NOT USE IN PRODUCTION. DO NOT USE IN PRODUCTION. feedbacks appreciated!

Examples

more examples here

fn main () {}

#[cfg(test)]
mod tests {
  extern crate qutonium;
  use qutonium::prelude::*;


  #[test]
  fn from_test () {
    // basic syntax
    suite!("the suite case name ~basic", {
      "compare integer" || {
        expect!(2 + 2).to(be_equal(4))?;
        expect!(0).not(be_equal(1))
      }

      "compare boolean" || {
        expect!(false).to(be_false())?;
        expect!(true).to(be_true())
      }

      "testing should panic" || {
        expect!(catch { panic!() }).to(abort())
      }
    });

    // sugar syntax
    suite!("the suite case name ~sugar", {
      "compare integer" || {
        must!(0; be 1)?;
        must!(0; ne 1)
      }

      "compare boolean" || {
        must!(false; be.falsy)?;
        must!(true; be.truthy)
      }

      "testing should panic" || {
        must!(catch panic!() to abort())
      }
    });
  }
}

Overview

The output format follow the syntax from crystal | ruby. s/o Siegfried Ehret

SUITE the suite case name
  TEST compare integer (0ms)
    ERROR
       👎 received: <0> expected: <1>
       📍 src/main.rs:7:7
    END
  END
  TEST compare boolean (0ms)
    SUCCESS
       👍 ok
       📍 src/main.rs:12:7
    END
  END
  TEST testing should panic (0ms)
    SUCCESS
       👍 ok
       📍 src/main.rs:16:7
    END
  END
END

DIAGNOSTIC
  👎 failed: 1   👍 passed: 2   📈 total: 3
END

Goals

  • describe suite case | suite!
  • test function |
  • assertions | expect
  • marker | not & to
  • matchers | see the complete list here
  • extended matchers
  • custom matchers
  • diagnostics
  • error location
  • helpful error messages
  • sugar syntax
  • no nested suites
  • colorized terminal output | using qute crate
  • snapshot diff | using differences crate
  • extended matchers
  • hooks | before:all, before:each, after:all and after:each
  • export json, xml | generic execution format for sonar (xml only)
  • Exclude test cases | skip and only
  • store | state container
  • should panic can be testing
  • writing unit testing
  • documentation

API

Exports

json

handler snippet
to_json suite!("my suite case name", {..}).to_json()

Markers

marker snippet
to expect!(0).to(matcher)
not expect!(1).not(matcher)

Matchers

boolean

matcher snippet
be_false expect!(0 == 1).to(be_false())
be_true expect!(0 == 0).to(be_true())

common

matcher snippet
be_equal expect!("helloworld").to(be_equal("helloworld))

License

Copyright Šī¸ 2020 Qurity

Released under the MIT license