peterfox / phpunit-toon-result-printer
A PHPUnit results printer that works with the TOON format
Fund package maintenance!
Peter Fox
Installs: 2
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 1
Open Issues: 0
pkg:composer/peterfox/phpunit-toon-result-printer
Requires
- php: ^8.4
- helgesverre/toon: ^3.1
- phpunit/phpunit: ^10.5.60|^11.5.48|^12.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.21.1
- peterfox/phpstan-toon-formatter: ^1.0
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.1
- spatie/ray: ^1.28
README
A PHPUnit results printer that outputs test results in TOON (Token-Oriented Object Notation) format.
This extension is specifically designed to provide compact, highly readable test results optimized for LLM (Large Language Model) consumption, helping AI agents quickly diagnose test failures.
Features
- Compact Output: Uses TOON format to minimize token usage while remaining human-readable.
- AI-Friendly Diagnostics: Includes file paths, line numbers, error messages, and stack traces for failed and errored tests.
- Concise Success Reports: Passed tests only show the test name and status to keep the output focused on what needs attention.
- PHPUnit Extension: Integrates seamlessly as a PHPUnit extension.
Installation
You can install the package via composer:
composer require peterfox/phpunit-toon-result-printer --dev
Configuration
Permanent (Recommended)
To use this printer, add it as an extension in your phpunit.xml or phpunit.xml.dist file:
<extensions> <bootstrap class="PeterFox\PhpUnitToonResultPrinter\ToonResultPrinterExtension" /> </extensions>
When enabled, it will suppress PHPUnit's default progress and result output, replacing it with TOON-formatted output at the end of the test execution.
Manual (CLI)
If you don't want to enable it for all test runs, you can trigger it manually using the --extension flag:
vendor/bin/phpunit --extension "PeterFox\PhpUnitToonResultPrinter\ToonResultPrinterExtension"
Example Output
For a passing test:
ok
For a failing test:
test: "Tests\\ExampleTest::test_it_fails"
status: failed
file: "tests/ExampleTest.php"
line: 16
message: "Failed asserting that false is true."
description: "Failed asserting that false is true."
stackTrace: "..."
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.