archunit/testing/
test_violation.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
/// One human-readable rendering of structured architecture-violation data.
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct TestViolation {
    /// The short violation category or custom requirement.
    pub message: String,
    /// The evidence and relationship that explain the failure.
    pub details: String,
}

impl TestViolation {
    /// Creates one framework-neutral violation rendering.
    #[must_use]
    pub fn new(message: impl Into<String>, details: impl Into<String>) -> Self {
        Self {
            message: message.into(),
            details: details.into(),
        }
    }
}

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

    #[test]
    fn owns_message_and_details_as_plain_data() {
        let violation = TestViolation::new("File dependency violation", "api -> database");

        assert_eq!(violation.message, "File dependency violation");
        assert_eq!(violation.details, "api -> database");
    }
}