pub struct Report {
pub name: XmlString,
pub uuid: Option<ReportUuid>,
pub timestamp: Option<DateTime<FixedOffset>>,
pub time: Option<Duration>,
pub tests: usize,
pub failures: usize,
pub errors: usize,
pub test_suites: Vec<TestSuite>,
}Expand description
The root element of a JUnit report.
Fields§
§name: XmlStringThe name of this report.
uuid: Option<ReportUuid>A unique identifier associated with this report.
This is an extension to the spec that’s used by nextest.
timestamp: Option<DateTime<FixedOffset>>The time at which the first test in this report began execution.
This is not part of the JUnit spec, but may be useful for some tools.
time: Option<Duration>The overall time taken by the test suite.
This is serialized as the number of seconds.
tests: usizeThe total number of tests from all TestSuites.
failures: usizeThe total number of failures from all TestSuites.
errors: usizeThe total number of errors from all TestSuites.
test_suites: Vec<TestSuite>The test suites contained in this report.
Implementations§
Source§impl Report
impl Report
Sourcepub fn deserialize<R: BufRead>(reader: R) -> Result<Self, DeserializeError>
pub fn deserialize<R: BufRead>(reader: R) -> Result<Self, DeserializeError>
Experimental: Deserializes a JUnit XML report from a reader.
The deserializer should work with JUnit reports generated by the
quick-junit crate, but might not work with JUnit reports generated by
other tools. Patches to fix this are welcome.
§Errors
Returns an error if the XML is malformed, or if required attributes are missing.
Sourcepub fn deserialize_from_str(xml: &str) -> Result<Self, DeserializeError>
pub fn deserialize_from_str(xml: &str) -> Result<Self, DeserializeError>
Deserializes a JUnit XML report from a string.
§Errors
Returns an error if the XML is malformed, or if required attributes are missing.
§Examples
use quick_junit::Report;
let xml = r#"<?xml version="1.0" encoding="UTF-8"?>
<testsuites name="my-test-run" tests="1" failures="0" errors="0">
<testsuite name="my-test-suite" tests="1" disabled="0" errors="0" failures="0">
<testcase name="success-case"/>
</testsuite>
</testsuites>
"#;
let report = Report::deserialize_from_str(xml).unwrap();
assert_eq!(report.name.as_str(), "my-test-run");
assert_eq!(report.tests, 1);Source§impl Report
impl Report
Sourcepub fn set_report_uuid(&mut self, uuid: ReportUuid) -> &mut Self
pub fn set_report_uuid(&mut self, uuid: ReportUuid) -> &mut Self
Sets a unique ID for this Report.
This is an extension that’s used by nextest.
Sourcepub fn set_uuid(&mut self, uuid: Uuid) -> &mut Self
pub fn set_uuid(&mut self, uuid: Uuid) -> &mut Self
Sets a unique ID for this Report from an untyped Uuid.
This is an extension that’s used by nextest.
Sourcepub fn set_timestamp(
&mut self,
timestamp: impl Into<DateTime<FixedOffset>>,
) -> &mut Self
pub fn set_timestamp( &mut self, timestamp: impl Into<DateTime<FixedOffset>>, ) -> &mut Self
Sets the start timestamp for the report.
Sourcepub fn set_time(&mut self, time: Duration) -> &mut Self
pub fn set_time(&mut self, time: Duration) -> &mut Self
Sets the time taken for overall execution.
Sourcepub fn add_test_suite(&mut self, test_suite: TestSuite) -> &mut Self
pub fn add_test_suite(&mut self, test_suite: TestSuite) -> &mut Self
Adds a new TestSuite and updates the tests, failures and errors counts.
When generating a new report, use of this method is recommended over adding to
self.TestSuites directly.
Sourcepub fn add_test_suites(
&mut self,
test_suites: impl IntoIterator<Item = TestSuite>,
) -> &mut Self
pub fn add_test_suites( &mut self, test_suites: impl IntoIterator<Item = TestSuite>, ) -> &mut Self
Adds several TestSuites and updates the tests, failures and errors counts.
When generating a new report, use of this method is recommended over adding to
self.TestSuites directly.
Sourcepub fn serialize(&self, writer: impl Write) -> Result<(), SerializeError>
pub fn serialize(&self, writer: impl Write) -> Result<(), SerializeError>
Serialize this report to the given writer.
Sourcepub fn to_string(&self) -> Result<String, SerializeError>
pub fn to_string(&self) -> Result<String, SerializeError>
Serialize this report to a string.
Trait Implementations§
impl Eq for Report
impl StructuralPartialEq for Report
Auto Trait Implementations§
impl Freeze for Report
impl RefUnwindSafe for Report
impl Send for Report
impl Sync for Report
impl Unpin for Report
impl UnwindSafe for Report
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.