junit-parser 1.5.1

Rust library to parse JUnit XML files
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Project Overview

This is a Rust library for parsing JUnit XML files. The library provides structured data types to represent JUnit test reports including test suites, test cases, and various test outcomes (success, failure, error, skipped).

## Development Commands

### Building
- `cargo build` - Build the project with default features
- `cargo build --no-default-features` - Build without any features
- `cargo build --release` - Build optimized release version

### Testing
- `cargo test` - Run all tests with default features
- `cargo test --no-default-features` - Run tests without features
- Run individual test files: `cargo test --test <test_name>` (e.g., `cargo test --test properties`)

### Code Quality
- `cargo fmt` - Format code
- `cargo fmt --check` - Check if code is formatted
- `cargo clippy` - Run linter
- `cargo clippy -- -D warnings` - Run linter treating warnings as errors
- `cargo check` - Fast compile check without producing binaries

### Documentation
- `cargo doc` - Generate documentation
- `cargo doc --open` - Generate and open documentation

### CI Script
The project includes a comprehensive CI script at `.github/scripts/ci.bash` that runs various combinations of features:
- `.github/scripts/ci.bash fmt` - Format check
- `.github/scripts/ci.bash check` - Compile check
- `.github/scripts/ci.bash clippy` - Linting
- `.github/scripts/ci.bash test` - Tests
- `.github/scripts/ci.bash build` - Build
- `.github/scripts/ci.bash doc` - Documentation

## Code Architecture

### Core Components

1. **Main Library (`src/lib.rs`)**: Contains the primary parsing logic and data structures
   - `TestSuites`: Root structure containing multiple test suites
   - `TestSuite`: Individual test suite containing test cases and metadata
   - `TestCase`: Individual test case with status and metadata
   - `TestStatus`: Enum representing test outcomes (Success, Error, Failure, Skipped)

2. **Error Handling (`src/errors.rs`)**: Comprehensive error types using `thiserror`
   - XML parsing errors
   - Encoding/decoding errors
   - Attribute conversion errors

3. **Test Files (`tests/`)**: Extensive test coverage including:
   - Basic parsing tests (`tests.rs`)
   - Property parsing (`properties.rs`)
   - System output handling (`system.rs`)
   - CDATA support (`cdata.rs`)
   - Rerun/flaky test support (`reruns.rs`)
   - Invalid XML handling (`invalid.rs`)
   - Unknown tag handling (`unknown_tags.rs`)

### Features

The library uses Cargo features for optional functionality:
- `serde`: Enables Serde serialization/deserialization
- `properties_as_hashmap`: Parse properties as HashMap (default)
- `properties_as_vector`: Parse properties as Vec (default)
- `document-features`: For documentation generation

### Key Parsing Logic

The parser handles various JUnit XML formats:
- Root elements: `<testsuites>`, `<testrun>`, or single `<testsuite>`
- Supports nested test suites
- Handles empty elements and start/end tag pairs
- Processes CDATA sections and text content
- Supports rerun/flaky test extensions
- Parses system-out and system-err elements
- Handles properties as both HashMap and Vec

### Dependencies

- `quick-xml`: Core XML parsing (v0.38)
- `thiserror`: Error handling (v2.0)
- `serde`: Optional serialization support (v1.0)

## Development Notes

- The codebase uses `#![forbid(unsafe_code)]` and `#![deny(missing_docs)]`
- Comprehensive error handling with custom error types
- Extensive test coverage with real-world XML examples
- Feature flags allow flexible compilation based on needs
- CI runs tests across all feature combinations