PHPackages                             testmonitor/junit-xml-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. testmonitor/junit-xml-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

testmonitor/junit-xml-parser
============================

This package provides a very basic, convenient parser for JUnit XML reports.

v1.1.0(7mo ago)1338↓50%1MITPHPPHP ^8.3

Since May 1Pushed 6mo ago2 watchersCompare

[ Source](https://github.com/testmonitor/junit-xml-parser)[ Packagist](https://packagist.org/packages/testmonitor/junit-xml-parser)[ RSS](/packages/testmonitor-junit-xml-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (4)Used By (0)

JUnit XML Parser
================

[](#junit-xml-parser)

[![Latest Stable Version](https://camo.githubusercontent.com/720ccc1872cbd475b8c0039b6176661d905dbce1a13b11984e1fd1eeb3ae0d55/68747470733a2f2f706f7365722e707567782e6f72672f746573746d6f6e69746f722f6a756e69742d786d6c2d7061727365722f762f737461626c65)](https://packagist.org/packages/testmonitor/junit-xml-parser)[![CircleCI](https://camo.githubusercontent.com/51c77789c87d43ad38d4e0d093d7f20bc74184b68e5845c3277d61f525b14ad4/68747470733a2f2f696d672e736869656c64732e696f2f636972636c6563692f70726f6a6563742f6769746875622f746573746d6f6e69746f722f6a756e69742d786d6c2d7061727365722e737667)](https://circleci.com/gh/testmonitor/junit-xml-parser)[![StyleCI](https://camo.githubusercontent.com/7081e978bfe8f4b6612d029862f057795ce0c90c8f722be8bdcffc93be513921/68747470733a2f2f7374796c6563692e696f2f7265706f732f3933343239393332392f736869656c64)](https://styleci.io/repos/934299329)[![codecov](https://camo.githubusercontent.com/4360ccde7e53885dc134a300f280504127ec0f47e036cc7ea865d11f9efd1162/68747470733a2f2f636f6465636f762e696f2f67682f746573746d6f6e69746f722f6a756e69742d786d6c2d7061727365722f67726170682f62616467652e7376673f746f6b656e3d4f583630395930494a59)](https://codecov.io/gh/testmonitor/junit-xml-parser)[![License](https://camo.githubusercontent.com/ee43b156f065af84020b42a52819b1b2b673a197086a888c54b7cf0fdd07fc31/68747470733a2f2f706f7365722e707567782e6f72672f746573746d6f6e69746f722f6a756e69742d786d6c2d7061727365722f6c6963656e7365)](https://packagist.org/packages/testmonitor/junit-xml-parser)

This package provides a very basic, convenient parser for JUnit XML reports.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Tests](#tests)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Installation
------------

[](#installation)

To install the client you need to require the package using composer:

```
$ composer require testmonitor/junit-xml-parser

```

Use composer's autoload:

```
require __DIR__.'/../vendor/autoload.php';
```

You're all set up now!

Usage
-----

[](#usage)

Include the parser in your project:

```
use TestMonitor\JUnitXmlParser\JUnitXmlParser;

$parser = new JUnitXmlParser();
$testSuites = $parser->parse('path/to/junit.xml');
```

Examples
--------

[](#examples)

Below are some examples demonstrating how to use the JUnit XML Parser to extract and process test results.

### Parsing a JUnit XML file

[](#parsing-a-junit-xml-file)

This example shows how to parse a JUnit XML report and retrieve test suite and test case information.

```
use TestMonitor\JUnitXmlParser\JUnitXmlParser;

$parser = new JUnitXmlParser();
$testSuites = $parser->parse('tests/results.xml');

foreach ($testSuites as $suite) {
    echo "Suite: " . $suite->getName() . "\n";

    foreach ($suite->getTestCases() as $testCase) {
        echo "  Test: " . $testCase->getName() . " - Status: " . $testCase->getStatus()->name . "\n";
    }
}
```

### Processing Failures and Skipped Tests

[](#processing-failures-and-skipped-tests)

This example demonstrates how to identify and handle failed and skipped test cases.

```
use TestMonitor\JUnitXmlParser\JUnitXmlParser;

$parser = new JUnitXmlParser();
$testSuites = $parser->parse('tests/results.xml');

foreach ($testSuites as $suite) {
    foreach ($suite->getTestCases() as $testCase) {
        if ($testCase->getStatus() === TestStatus::FAILED) {
            echo "Test " . $testCase->getName() . " failed: " . $testCase->getFailureMessage() . "\n";
        } elseif ($testCase->getStatus() === TestStatus::SKIPPED) {
            echo "Test " . $testCase->getName() . " was skipped.\n";
        }
    }
}
```

### Handling Properties

[](#handling-properties)

This example demonstrates how to retrieve the property keys and values:

```
use TestMonitor\JUnitXmlParser\JUnitXmlParser;

$parser = new JUnitXmlParser();
$result = $parser->parse('tests/results.xml');

foreach ($result->getTestSuites() as $suite) {
    echo "Suite: {$suite->getName()}\n";

    foreach ($suite->getProperties() as $key => $value) {
        echo "$key: $value\n";
    }
}
```

### Processing System Out and System Err

[](#processing-system-out-and-system-err)

This example demonstrates how to retrieve the information for the system-out and system-err tags:

```
use TestMonitor\JUnitXmlParser\JUnitXmlParser;
use TestMonitor\JUnitXmlParser\Enums\TestStatus;

$parser = new JUnitXmlParser();
$result = $parser->parse('tests/results.xml');

foreach ($result->getTestSuites() as $suite) {
    foreach ($suite->getTestCases() as $testCase) {
        if ($testCase->getStatus() === TestStatus::PASSED) {
            echo "Test '{$testCase->getName()}' passed:\n";
            echo $testCase->getSystemOut() . "\n\n";
        } else {
            echo "Test '{$testCase->getName()}' didn't pass:\n";
            echo $testCase->getSystemErr() . "\n\n";
        }
    }
}
```

### Extracting Execution Time and Timestamp

[](#extracting-execution-time-and-timestamp)

JUnit XML reports include execution times and timestamps, which can be accessed as shown below.

```
use TestMonitor\JUnitXmlParser\JUnitXmlParser;

$parser = new JUnitXmlParser();
$testSuites = $parser->parse('tests/results.xml');

foreach ($testSuites as $suite) {
    echo "Suite: " . $suite->getName() . " executed in " . $suite->getDuration() . " seconds on " . $suite->getTimestamp() . "\n";
}
```

Tests
-----

[](#tests)

The package contains integration tests. You can run them using PHPUnit.

```
$ vendor/bin/phpunit

```

Changelog
---------

[](#changelog)

Refer to [CHANGELOG](CHANGELOG.md) for more information.

Contributing
------------

[](#contributing)

Refer to [CONTRIBUTING](CONTRIBUTING.md) for contributing details.

Credits
-------

[](#credits)

- **Thijs Kok** - *Lead developer* - [ThijsKok](https://github.com/thijskok)
- **Stephan Grootveld** - *Developer* - [Stefanius](https://github.com/stefanius)
- **Frank Keulen** - *Developer* - [FrankIsGek](https://github.com/frankisgek)

License
-------

[](#license)

The MIT License (MIT). Refer to the [License](LICENSE.md) for more information.

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance64

Regular maintenance activity

Popularity18

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

2

Last Release

236d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/39f48c881813b7d3b044ca5660aa5ab9e60b5dd7c34ed4a47acbb11bd20b7593?d=identicon)[thijskok](/maintainers/thijskok)

---

Top Contributors

[![thijskok](https://avatars.githubusercontent.com/u/1344550?v=4)](https://github.com/thijskok "thijskok (35 commits)")[![StyleCIBot](https://avatars.githubusercontent.com/u/11048387?v=4)](https://github.com/StyleCIBot "StyleCIBot (2 commits)")[![stefanius](https://avatars.githubusercontent.com/u/2707905?v=4)](https://github.com/stefanius "stefanius (1 commits)")

---

Tags

xmlparserjunittestmonitor

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/testmonitor-junit-xml-parser/health.svg)

```
[![Health](https://phpackages.com/badges/testmonitor-junit-xml-parser/health.svg)](https://phpackages.com/packages/testmonitor-junit-xml-parser)
```

###  Alternatives

[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[imangazaliev/didom

Simple and fast HTML parser

2.2k2.3M64](/packages/imangazaliev-didom)[orchestra/parser

XML Document Parser for Laravel and PHP

4581.7M5](/packages/orchestra-parser)[laravie/parser

XML Document Parser for PHP

2342.1M8](/packages/laravie-parser)[goetas-webservices/xsd-reader

Read any XML Schema (XSD) programmatically with PHP

624.7M15](/packages/goetas-webservices-xsd-reader)[vipnytt/sitemapparser

XML Sitemap parser class compliant with the Sitemaps.org protocol.

772.2M10](/packages/vipnytt-sitemapparser)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
