https://github.com/ergebnis/phpunit-agent-reporter
🤖 Provides an extension for reporting phpunit/phpunit test execution details to agents.
https://github.com/ergebnis/phpunit-agent-reporter
agent extension php phpunit reporter
Last synced: about 1 month ago
JSON representation
🤖 Provides an extension for reporting phpunit/phpunit test execution details to agents.
- Host: GitHub
- URL: https://github.com/ergebnis/phpunit-agent-reporter
- Owner: ergebnis
- License: mit
- Created: 2026-04-01T16:17:17.000Z (2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-22T05:19:32.000Z (about 2 months ago)
- Last Synced: 2026-04-22T07:29:41.407Z (about 2 months ago)
- Topics: agent, extension, php, phpunit, reporter
- Language: PHP
- Size: 314 KB
- Stars: 7
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# phpunit-agent-reporter
[](https://github.com/ergebnis/phpunit-agent-reporter/actions)
[](https://github.com/ergebnis/phpunit-agent-reporter/actions)
[](https://github.com/ergebnis/phpunit-agent-reporter/actions)
[](https://github.com/ergebnis/phpunit-agent-reporter/actions)
[](https://github.com/ergebnis/phpunit-agent-reporter/actions)
[](https://codecov.io/gh/ergebnis/phpunit-agent-reporter)
[](https://packagist.org/packages/ergebnis/phpunit-agent-reporter)
[](https://packagist.org/packages/ergebnis/phpunit-agent-reporter)
[](https://packagist.org/packages/ergebnis/phpunit-agent-reporter)
This project provides a [`composer`](https://getcomposer.org) package and a [Phar archive](https://www.php.net/manual/en/book.phar.php) with an extension for reporting [`phpunit/phpunit`](https://github.com/sebastianbergmann/phpunit) test execution details to agents.
## Example
After installing and bootstrapping the extension, when running your tests with `phpunit/phpunit`, the extension will detect whether an agent is running the tests and replace the default output with test execution details that are easier for agents to consume.
When tests pass, the extension outputs:
```json
{
"result": "success",
"summary": {
"assertions": 5,
"errors": 0,
"failures": 0,
"tests": 5,
"warnings": 0
}
}
```
When tests fail (exit code 1), the extension outputs:
```json
{
"result": "failure",
"summary": {
"assertions": 5,
"errors": 0,
"failures": 2,
"tests": 5,
"warnings": 0
},
"details": {
"failures": [
{
"file": "/path/to/ExampleTest.php",
"line": 27,
"message": "Failed asserting that false is true.",
"test": "Namespace\\ExampleTest::testFailing"
},
{
"actual": "bar",
"diff": "--- Expected\n+++ Actual\n@@ @@\n-'foo'\n+'bar'\n",
"expected": "foo",
"file": "/path/to/ExampleTest.php",
"line": 34,
"message": "Failed asserting that two strings are identical.",
"test": "Namespace\\ExampleTest::testComparisonFailing"
}
]
}
}
```
When tests fail with comparison assertions, the `actual`, `diff`, and `expected` fields provide details about the mismatch. These fields are only present for comparison failures.
When tests error (exit code 2), the extension outputs:
```json
{
"result": "exception",
"summary": {
"assertions": 5,
"errors": 1,
"failures": 2,
"tests": 5,
"warnings": 0
},
"details": {
"errors": [
{
"file": "/path/to/ExampleTest.php",
"line": 32,
"message": "Something went wrong.",
"test": "Namespace\\ExampleTest::testErroring"
}
],
"failures": [
{
"file": "/path/to/ExampleTest.php",
"line": 27,
"message": "Failed asserting that false is true.",
"test": "Namespace\\ExampleTest::testFailing"
},
{
"actual": "bar",
"diff": "--- Expected\n+++ Actual\n@@ @@\n-'foo'\n+'bar'\n",
"expected": "foo",
"file": "/path/to/ExampleTest.php",
"line": 34,
"message": "Failed asserting that two strings are identical.",
"test": "Namespace\\ExampleTest::testComparisonFailing"
}
]
}
}
```
The JSON output conforms to the [JSON schema](schema/agent-report-schema.json) included in this package.
### Agent Detection
The extension uses [`ergebnis/agent-detector`](https://github.com/ergebnis/agent-detector) to detect the presence of agents.
## Compatibility
The extension is compatible with the following versions of `phpunit/phpunit`:
- [`phpunit/phpunit:^13.0.0`](https://github.com/sebastianbergmann/phpunit/tree/13.0.0)
- [`phpunit/phpunit:^12.0.0`](https://github.com/sebastianbergmann/phpunit/tree/12.0.0)
- [`phpunit/phpunit:^11.0.0`](https://github.com/sebastianbergmann/phpunit/tree/11.0.0)
- [`phpunit/phpunit:^10.0.0`](https://github.com/sebastianbergmann/phpunit/tree/10.0.0)
## Installation
### Installation with `composer`
Run
```sh
composer require --dev ergebnis/phpunit-agent-reporter
```
to install `ergebnis/phpunit-agent-reporter` as a `composer` package.
### Installation as Phar
Download `phpunit-agent-reporter.phar` from the [latest release](https://github.com/ergebnis/phpunit-agent-reporter/releases/latest).
## Usage
### Bootstrapping the extension
Before the extension can report test execution details in `phpunit/phpunit`, you need to bootstrap it.
### Bootstrapping the extension as a `composer` package
To bootstrap the extension as a `composer` package when using
- `phpunit/phpunit:^13.0.0`
- `phpunit/phpunit:^12.0.0`
- `phpunit/phpunit:^11.0.0`
- `phpunit/phpunit:^10.0.0`
adjust your `phpunit.xml` configuration file and configure the
- [`extensions` element](https://docs.phpunit.de/en/13.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^13.0.0`](https://docs.phpunit.de/en/13.0/)
- [`extensions` element](https://docs.phpunit.de/en/12.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^12.0.0`](https://docs.phpunit.de/en/12.0/)
- [`extensions` element](https://docs.phpunit.de/en/11.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^11.0.0`](https://docs.phpunit.de/en/11.0/)
- [`extensions` element](https://docs.phpunit.de/en/10.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^10.0.0`](https://docs.phpunit.de/en/10.5/)
```diff
+
+
+
test/Unit/
```
### Bootstrapping the extension as a PHAR
To bootstrap the extension as a PHAR when using
- `phpunit/phpunit:^13.0.0`
- `phpunit/phpunit:^12.0.0`
- `phpunit/phpunit:^11.0.0`
- `phpunit/phpunit:^10.0.0`
adjust your `phpunit.xml` configuration file and configure the
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/13.0/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/13.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^13.0.0`](https://docs.phpunit.de/en/13.0/)
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/12.0/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/12.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^12.0.0`](https://docs.phpunit.de/en/12.0/)
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/11.0/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/11.0/configuration.html#the-extensions-element) on [`phpunit/phpunit:^11.0.0`](https://docs.phpunit.de/en/11.0/)
- [`extensionsDirectory` attribute](https://docs.phpunit.de/en/10.5/configuration.html#the-extensionsdirectory-attribute) and the [`extensions` element](https://docs.phpunit.de/en/10.5/configuration.html#the-extensions-element) on [`phpunit/phpunit:^10.0.0`](https://docs.phpunit.de/en/10.5/)
```diff
+
+
+
test/Unit/
```
## Changelog
The maintainers of this project record notable changes to this project in a [changelog](CHANGELOG.md).
## Contributing
The maintainers of this project suggest following the [contribution guide](.github/CONTRIBUTING.md).
## Code of Conduct
The maintainers of this project ask contributors to follow the [code of conduct](.github/CODE_OF_CONDUCT.md).
## General Support Policy
The maintainers of this project provide limited support.
You can support the maintenance of this project by [sponsoring @ergebnis](https://github.com/sponsors/ergebnis).
## PHP Version Support Policy
This project currently supports the following PHP versions:
- [PHP 8.1](https://www.php.net/releases/#8.1.0) (has reached its end of life on December 31, 2025)
- [PHP 8.2](https://www.php.net/releases/#8.2.0)
- [PHP 8.3](https://www.php.net/releases/#8.3.0)
- [PHP 8.4](https://www.php.net/releases/#8.4.0)
- [PHP 8.5](https://www.php.net/releases/#8.5.0)
The maintainers of this project add support for a PHP version following its initial release and _may_ drop support for a PHP version when it has reached its [end of life](https://www.php.net/supported-versions.php).
## Security Policy
This project has a [security policy](.github/SECURITY.md).
## License
This project uses the [MIT license](LICENSE.md).
## Credits
This package is inspired by [`nunomaduro/pao`](https://github.com/nunomaduro/pao), originally licensed under MIT by [Nuno Maduro](https://github.com/nunomaduro).
## Social
Follow [@localheinz](https://twitter.com/intent/follow?screen_name=localheinz) and [@ergebnis](https://twitter.com/intent/follow?screen_name=ergebnis) on Twitter.