#test #testing #testing #framework #substance

macro no-std substance-macro

The macro crate for the Substance Framework testing suite

3 unstable releases

Uses new Rust 2021

0.2.0-alpha Apr 27, 2022
0.1.1-alpha Mar 21, 2022
0.1.0-alpha Mar 18, 2022

#206 in Testing

24 downloads per month
Used in substance-framework

MIT license

52 lines

Substance Framework

Substance Framework is a [no_std] testing framework for rust and cargo that can work even with custom target. It enabling you to perform units testing on Core-only project (without the need to build sdt for the target). The framework relies on some nightly features to provide a complete system that can handle most of the hard work for you.

Any project that require a target without std support (minimalistic target or custom system) can use this project to avoid the need to reimplement a test runner as it is described in the unstable book.

This project is under the


  • Provide a working no_std runner for unit testing
  • Display a nice interface with the result
  • handle true panic and abort all the tests
  • provide a simple macro to put on your testing function
  • provide a set of assertion that replace the default one


A short introduction


extern crate substance_framework;
extern crate substance_macro;

mod tests {
    fn test_equals() {
        sf_assert_eq!(0, 0);

    fn test_non_equals() {
        sf_assert_ne!(0, -1);

    fn test_lower() {
        sf_assert_lt!(0, 1);

    fn test_lower_or_equals() {
        sf_assert_le!(0, 0);

    fn test_greater() {
        sf_assert_gt!(7, -1);

    fn test_greater_or_equals() {
        sf_assert_ge!(0, -1);

    fn test_is_true() {
        sf_assert!(53 != 54);

    fn test_failure() {
        sf_assert!(53 == 54);

    fn test_failure_with_msg() {
        sf_assert!(53 == 54, "I'm a bad little test");

    fn test_should_fail() {

    fn test_is_true_to_ignore() {
        sf_assert!(false, "shouldn't be visible");

    fn test_panic() {

    fn test_panic_with_message() {

    fn test_panic_with_arguments() {
        panic!("{}{}{}", "Y", "E", "AAAAAA");

    #[substance_test("Should_panic", "Ignore")]
    fn test_panic_ignored() {

Minimum supported Rust version

You must use at least Rust nightly-2022-02-12 because the crate depend on some unstable features. Those are required to provide the test runner and manage a panic handler that can manage most case safely.


  • Provide macro to ease the usage of this library => first iteration

  • Provide macro replacement for assertion (default one use panic implementation directly)

  • Get a UI upgrade => using the libc crate to access STDOUT

  • Support JUnit-like XML report generation => basic system

  • Provide Setup() and TearDown()

  • Implement a full XUnit system

  • Provide a comprehensive declarative system to construct any assertion

  • Find a way to optimize the run time (core doesn't provide thread support)

  • etc.


~15K SLoC