Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 28, 2021 03:17 am GMT

unit test Rust

unit test Rust file code integration test /tests /src

unit test

fn add(a:i32, b:i32) -> i32 {a+b}fn main() {    println!("{}",add(1,2));}#[cfg(test)]mod tests {    #[test]    fn add_correct() {        assert_eq!(3, super::add(1,2));    }}

function add unit test code compile unit test

#[cfg(test)] mod tests compiler unit test compile

module tests function unit test #[test]

function super:: use super::*;

#[cfg(test)]mod tests {    use super::*;    #[test]    fn add_correct() {        assert_eq!(3, add(1,2));    }}

cargo test

unit test Rust


Original Link: https://dev.to/pallat/unit-test-rust-ggb

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To