Skip to content

Commit

Permalink
doc: add top-level example
Browse files Browse the repository at this point in the history
  • Loading branch information
borisfaure committed Sep 22, 2023
1 parent c3996be commit 6fa0465
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
#![warn(missing_docs)]
//! Library to parse JUnit XML files
//!
//! # Example
//!
//! Parsing a JUnit content
//!
//! ```
//! use std::io::Cursor;
//! let xml = r#"
//! <testsuite tests="3" failures="1">
//! <testcase classname="foo1" name="ASuccessfulTest"/>
//! <testcase classname="foo2" name="AnotherSuccessfulTest"/>
//! <testcase classname="foo3" name="AFailingTest">
//! <failure type="NotEnoughFoo"> details about failure </failure>
//! </testcase>
//! </testsuite>
//! "#;
//! let cursor = Cursor::new(xml);
//! let r = junit_parser::from_reader(cursor);
//! assert!(r.is_ok());
//! let t = r.unwrap();
//! assert_eq!(t.suites.len(), 1);
//! let ts = &t.suites[0];
//! assert_eq!(ts.tests, 3);
//! assert_eq!(ts.failures, 1);
//! assert_eq!(ts.cases.len(), 3);
//! assert!(ts.cases[0].status.is_success());
//! assert!(ts.cases[2].status.is_failure());
//! ```

/// Errors
mod errors;
Expand Down

0 comments on commit 6fa0465

Please sign in to comment.