Unit Testing Rust

Overview

Qualified supports writing tests for Rust using tests mod with #[cfg(test)] attibute.

Quick Start

pub fn add(a: i32, b: i32) -> i32 {
    a + b
}
#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_add() {
        assert_eq!(add(1, 1), 2);
    }
}

Learn More

You can learn more on the unit testing chapter in Rust by Example.