1 unstable release

0.1.0 Jun 17, 2021

#36 in #test-macro


Used in bern-test

MIT license

14KB
243 lines

bern-test-macros

Procedural macros for bern-test.

Documentation

License


lib.rs:

Bern Test macros.

Adapted from https://github.com/knurling-rs/defmt/blob/main/firmware/defmt-test/macros/src/lib.rs

Similar to defmt-test but can output on any interface (typically blocking) and can be run interactively (select a test via serial interface).

Example

/* Setup omitted */
#[bern_test::tests]
mod tests {
    #[test_set_up]
    fn base_setup() {
        // Run before every test
    }

    #[test_tear_down]
    fn reset() {
        // Runs after every test
        // For autorun this must be soft reset
        cortex_m::peripheral::SCB::sys_reset();
    }

    #[tear_down]
    fn stop() {
        // Runs after all tests
        cortex_m::asm::bkpt();
    }

    #[test]
    fn some_test() {
        assert_eq!(0, 1);
    }

    #[test]
    fn test_with_hardware(board: &mut Board) {
        // A test can use the argument given when the runner is started
        // from main
        board.led.set_high().ok();
        assert_eq!(board.led.is_high().unwrap(), true);
    }
}

Dependencies

~1.5MB
~35K SLoC