Report

Struct Report 

Source
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: XmlString

The 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: usize

The total number of tests from all TestSuites.

§failures: usize

The total number of failures from all TestSuites.

§errors: usize

The total number of errors from all TestSuites.

§test_suites: Vec<TestSuite>

The test suites contained in this report.

Implementations§

Source§

impl Report

Source

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.

Source

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

Source

pub fn new(name: impl Into<XmlString>) -> Self

Creates a new Report with the given name.

Source

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.

Source

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.

Source

pub fn set_timestamp( &mut self, timestamp: impl Into<DateTime<FixedOffset>>, ) -> &mut Self

Sets the start timestamp for the report.

Source

pub fn set_time(&mut self, time: Duration) -> &mut Self

Sets the time taken for overall execution.

Source

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.

Source

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.

Source

pub fn serialize(&self, writer: impl Write) -> Result<(), SerializeError>

Serialize this report to the given writer.

Source

pub fn to_string(&self) -> Result<String, SerializeError>

Serialize this report to a string.

Trait Implementations§

Source§

impl Clone for Report

Source§

fn clone(&self) -> Report

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Report

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Report

Source§

fn eq(&self, other: &Report) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Report

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.