Unit Testing Rust


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
mod tests {
    use super::*;

    fn test_add() {
        assert_eq!(add(1, 1), 2);

Learn More

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