1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Rust File: src/lib.rs
pub fn hello() -> &'static str {
    println!("{}", hallo());
    "Hello, World!"
}

fn hallo() -> &'static str {
    "Hallo, Welt!"
}

// BEGIN: unit tests for private code
// code 1
#[cfg(test)]
#[path = "./private_tests/owned_hello.rs"]
mod owned_hello;

// code 2
#[cfg(test)]
#[path = "./private_tests/mod.rs"]
mod private_tests;

// code 3
#[cfg(test)]
mod private_tests_with_use {
    use super::*;
    //use super::hallo;

    #[test]
    fn it_works_at_private() {
        assert_eq!("Hallo, Welt!", hallo());
    }
}

// code 4
#[cfg(test)]
mod private_tests_without_use {
    #[test]
    fn it_works_at_private() {
        assert_eq!("Hallo, Welt!", super::hallo());
    }
}
// END unit tests for private code 

// BEGIN: integration tests
#[cfg(test)]
#[path = "./integration_tests/i_hello.rs"]
mod i_hello;

#[cfg(test)]
#[path = "./integration_tests/mod.rs"]
mod integration_tests;
// END: integration tests