Last active
December 11, 2019 12:53
-
-
Save hoony-o-1/ce1819f1f9fbb7a3daa2deaf4fdc17cc to your computer and use it in GitHub Desktop.
unit test & integration test in Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tests/integration_test.rs | |
| use adder; | |
| mod common; | |
| #[test] | |
| fn add_two_test() { | |
| common::setup(); | |
| assert_eq!(adder::add_two(2), 4); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // src/lib.rs | |
| pub fn add_two(a: i32) -> i32 { | |
| a + 2 | |
| } | |
| #[cfg(test)] | |
| mod tests { | |
| use super::*; | |
| #[test] | |
| fn add_two_unit_test() { | |
| assert_eq!(add_two(2), 4); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // tests/common/mod.rs | |
| fn add_two_unit_test() { | |
| assert!(add_two(2) == 4); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment