Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Test coverage report with tarpaulin

#![allow(unused)]
fn main() {
pub fn add(left: usize, right: usize) -> usize {
    left + right
}

pub fn multiply(left: usize, right: usize) -> usize {
    left + right
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }
}
}
cargo install cargo-tarpaulin
cargo tarpaulin

Exclude the test functions from the report:

cargo tarpaulin --ignore-tests
  • Generate HTML report
cargo tarpaulin --ignore-tests -o Html