archunit/testing/
test_result.rs

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
/// A framework-neutral pass flag and its complete display message.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
#[must_use = "a shaped test result must be inspected or passed to a test integration"]
pub struct TestResult {
    /// Whether the observed architecture verdict matched the expectation.
    pub passed: bool,
    /// The complete success or failure message.
    pub message: String,
}

impl TestResult {
    /// Creates one framework-neutral test result.
    pub fn new(passed: bool, message: impl Into<String>) -> Self {
        Self {
            passed,
            message: message.into(),
        }
    }
}

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

    #[test]
    fn owns_the_pass_flag_and_complete_message() {
        let result = TestResult::new(false, "Found one violation");

        assert!(!result.passed);
        assert_eq!(result.message, "Found one violation");
    }
}