Skip to main content

allure_rust_commons/
model.rs

1//! Serializable Allure result model types.
2
3use serde::Serialize;
4
5/// Serialized Allure test result.
6#[derive(Debug, Clone, Default, Serialize)]
7#[serde(rename_all = "camelCase")]
8pub struct TestResult {
9    /// Unique test execution identifier.
10    pub uuid: String,
11    /// Display name shown in the report.
12    pub name: String,
13    /// Stable fully qualified test name.
14    pub full_name: Option<String>,
15    /// Explicit or derived history identifier.
16    pub history_id: Option<String>,
17    /// Explicit or derived logical test case identifier.
18    pub test_case_id: Option<String>,
19    /// Markdown description.
20    pub description: Option<String>,
21    /// HTML description.
22    pub description_html: Option<String>,
23    /// Final test status.
24    pub status: Option<Status>,
25    /// Details associated with the final test status.
26    pub status_details: Option<StatusDetails>,
27    /// Lifecycle stage of the test.
28    pub stage: Option<Stage>,
29    /// Labels attached to the test.
30    pub labels: Vec<Label>,
31    /// Links attached to the test.
32    pub links: Vec<Link>,
33    /// Test-level parameters.
34    pub parameters: Vec<Parameter>,
35    /// Top-level steps.
36    pub steps: Vec<StepResult>,
37    /// Test-level attachments.
38    pub attachments: Vec<Attachment>,
39    /// Hierarchical path that identifies the test in the integration root.
40    pub title_path: Option<Vec<String>>,
41    /// Start timestamp in milliseconds since the Unix epoch.
42    pub start: Option<i64>,
43    /// Stop timestamp in milliseconds since the Unix epoch.
44    pub stop: Option<i64>,
45}
46
47/// Serialized Allure fixture result.
48#[derive(Debug, Clone, Default, Serialize)]
49#[serde(rename_all = "camelCase")]
50pub struct FixtureResult {
51    /// Fixture display name.
52    pub name: String,
53    /// Final fixture status.
54    pub status: Option<Status>,
55    /// Details associated with the final fixture status.
56    pub status_details: Option<StatusDetails>,
57    /// Lifecycle stage of the fixture.
58    pub stage: Option<Stage>,
59    /// Steps recorded inside the fixture.
60    pub steps: Vec<StepResult>,
61    /// Attachments recorded on the fixture.
62    pub attachments: Vec<Attachment>,
63    /// Fixture parameters.
64    pub parameters: Vec<Parameter>,
65    /// Start timestamp in milliseconds since the Unix epoch.
66    pub start: Option<i64>,
67    /// Stop timestamp in milliseconds since the Unix epoch.
68    pub stop: Option<i64>,
69}
70
71/// Serialized Allure container result linking tests and fixtures.
72#[derive(Debug, Clone, Default, Serialize)]
73#[serde(rename_all = "camelCase")]
74pub struct TestResultContainer {
75    /// Unique container identifier.
76    pub uuid: String,
77    /// Optional container display name.
78    pub name: Option<String>,
79    /// UUIDs of test results linked to this container.
80    pub children: Vec<String>,
81    /// Markdown container description.
82    pub description: Option<String>,
83    /// HTML container description.
84    pub description_html: Option<String>,
85    /// Before fixtures owned by this container.
86    pub befores: Vec<FixtureResult>,
87    /// After fixtures owned by this container.
88    pub afters: Vec<FixtureResult>,
89    /// Links attached at container scope.
90    pub links: Vec<Link>,
91    /// Start timestamp in milliseconds since the Unix epoch.
92    pub start: Option<i64>,
93    /// Stop timestamp in milliseconds since the Unix epoch.
94    pub stop: Option<i64>,
95}
96
97/// Run-level diagnostics stored outside a single test result.
98#[derive(Debug, Clone, Default, Serialize)]
99#[serde(rename_all = "camelCase")]
100pub struct Globals {
101    /// Run-level attachments.
102    pub attachments: Vec<GlobalAttachment>,
103    /// Run-level errors.
104    pub errors: Vec<GlobalError>,
105}
106
107/// Run-level attachment entry.
108#[derive(Debug, Clone, Serialize)]
109#[serde(rename_all = "camelCase")]
110pub struct GlobalAttachment {
111    /// Attachment display name.
112    pub name: String,
113    /// Attachment source filename in the results directory.
114    pub source: String,
115    /// Attachment content type.
116    pub content_type: String,
117}
118
119/// Run-level error entry.
120#[derive(Debug, Clone, Serialize)]
121#[serde(rename_all = "camelCase")]
122pub struct GlobalError {
123    /// Error message.
124    pub message: String,
125    /// Optional stack trace or diagnostic text.
126    pub trace: Option<String>,
127}
128
129/// Allure categories file wrapper.
130#[derive(Debug, Clone, Default, Serialize)]
131pub struct Categories(pub Vec<Category>);
132
133/// Category rule used by Allure to group failures.
134#[derive(Debug, Clone, Serialize)]
135#[serde(rename_all = "camelCase")]
136pub struct Category {
137    /// Category display name.
138    pub name: String,
139    /// Optional category description.
140    pub description: Option<String>,
141    /// Statuses matched by this category.
142    pub matched_statuses: Option<Vec<Status>>,
143    /// Regular expression matched against status messages.
144    pub message_regex: Option<String>,
145    /// Regular expression matched against traces.
146    pub trace_regex: Option<String>,
147    /// Whether matched tests should be marked flaky.
148    pub flaky: Option<bool>,
149}
150
151/// Allure execution status.
152#[derive(Debug, Clone, Serialize)]
153#[serde(rename_all = "lowercase")]
154pub enum Status {
155    /// Successful execution.
156    Passed,
157    /// Assertion-like failure.
158    Failed,
159    /// Unexpected or infrastructure failure.
160    Broken,
161    /// Skipped, disabled, pending, or intentionally not executed.
162    Skipped,
163}
164
165/// Allure lifecycle stage.
166#[derive(Debug, Clone, Serialize)]
167#[serde(rename_all = "lowercase")]
168pub enum Stage {
169    /// Known before execution starts.
170    Scheduled,
171    /// Currently executing.
172    Running,
173    /// Fully completed.
174    Finished,
175    /// Not executed yet or pending.
176    Pending,
177    /// Aborted unexpectedly.
178    Interrupted,
179}
180
181/// Additional details for a status.
182#[derive(Debug, Clone, Default, Serialize)]
183#[serde(rename_all = "camelCase")]
184pub struct StatusDetails {
185    /// Human-readable status message.
186    pub message: Option<String>,
187    /// Stack trace or diagnostic trace.
188    pub trace: Option<String>,
189    /// Actual value captured for assertion-style failures.
190    pub actual: Option<String>,
191    /// Expected value captured for assertion-style failures.
192    pub expected: Option<String>,
193}
194
195/// Allure label.
196#[derive(Debug, Clone, Serialize)]
197pub struct Label {
198    /// Label name.
199    pub name: String,
200    /// Label value.
201    pub value: String,
202}
203
204/// Allure link.
205#[derive(Debug, Clone, Serialize)]
206pub struct Link {
207    /// Optional display name.
208    pub name: Option<String>,
209    /// Link URL.
210    pub url: String,
211    /// Optional link type such as `issue` or `tms`.
212    #[serde(rename = "type")]
213    pub link_type: Option<String>,
214}
215
216/// Allure parameter.
217#[derive(Debug, Clone, Serialize)]
218pub struct Parameter {
219    /// Parameter name.
220    pub name: String,
221    /// Parameter value.
222    pub value: String,
223    /// Whether the parameter is excluded from history identity.
224    pub excluded: Option<bool>,
225    /// Optional display mode.
226    pub mode: Option<ParameterMode>,
227}
228
229/// Parameter display mode.
230#[derive(Debug, Clone, Serialize)]
231#[serde(rename_all = "lowercase")]
232pub enum ParameterMode {
233    /// Show the value normally.
234    Default,
235    /// Show the parameter name but hide the value.
236    Masked,
237    /// Hide the parameter from report display.
238    Hidden,
239}
240
241/// Allure attachment reference.
242#[derive(Debug, Clone, Serialize)]
243pub struct Attachment {
244    /// Attachment display name.
245    pub name: String,
246    /// Attachment source filename in the results directory.
247    pub source: String,
248    /// Attachment content type.
249    #[serde(rename = "type")]
250    pub content_type: String,
251}
252
253/// Serialized Allure step result.
254#[derive(Debug, Clone, Default, Serialize)]
255#[serde(rename_all = "camelCase")]
256pub struct StepResult {
257    /// Optional step identifier.
258    pub uuid: Option<String>,
259    /// Step display name.
260    pub name: String,
261    /// Final step status.
262    pub status: Option<Status>,
263    /// Details associated with the final step status.
264    pub status_details: Option<StatusDetails>,
265    /// Lifecycle stage of the step.
266    pub stage: Option<Stage>,
267    /// Nested steps.
268    pub steps: Vec<StepResult>,
269    /// Attachments stored on the step.
270    pub attachments: Vec<Attachment>,
271    /// Step-level parameters.
272    pub parameters: Vec<Parameter>,
273    /// Start timestamp in milliseconds since the Unix epoch.
274    pub start: Option<i64>,
275    /// Stop timestamp in milliseconds since the Unix epoch.
276    pub stop: Option<i64>,
277}