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.
- 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.
You can install the package via composer:
composer require peterfox/phpunit-toon-result-printer --devTo 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.
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"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: "..."
composer testPlease see CHANGELOG for more information on what has changed recently.
The MIT License (MIT). Please see License File for more information.