barthy-koeln/beautify-specify
Adds colored, more informative terminal output for PHPUnit tests using Codeception/Specify. Install as a dev dependency, set phpunit printerClass to ResultPrinter, and swap in the provided Specify trait to enhance Specify’s output formatting.
Installation Add the package via Composer:
composer require barthy-koeln/beautify-specify --dev
Register the service provider in config/app.php under providers:
BarthyKoeln\BeautifySpecify\BeautifySpecifyServiceProvider::class,
First Use Case
Run PHPUnit with the --specify flag (if not already configured):
./vendor/bin/phpunit --specify
The package will automatically enhance the output with colors and structured formatting.
Where to Look First
config/beautify-specify.php (if generated) for customization options.README.md (if available) for basic usage examples.src/BeautifySpecifyServiceProvider.php and src/BeautifySpecify.php for core logic.Automated Testing Workflow
- run: ./vendor/bin/phpunit --specify --coverage-text
Customizing Output
// config/beautify-specify.php
return [
'colors' => [
'passed' => '#2ecc71', // Green
'failed' => '#e74c3c', // Red
'skipped' => '#f39c12', // Orange
],
];
Integration with Laravel Testing
phpunit.xml by extending the default configuration:
<phpunit>
<extensions>
<extension class="BarthyKoeln\BeautifySpecify\BeautifySpecifyExtension"/>
</extensions>
</phpunit>
Dynamic Test Grouping
@group annotations to visually separate test suites in the output.Archived Package
Color Compatibility
--no-colors flag if colors cause issues.Configuration Overrides
config/beautify-specify.php file isn’t generated, manually create it in the config directory.php artisan vendor:publish --provider="BarthyKoeln\BeautifySpecify\BeautifySpecifyServiceProvider"
PHPUnit Version Conflicts
Disable Formatting Temporarily disable the package to isolate issues:
./vendor/bin/phpunit --specify --no-beautify-specify
(Note: This flag may not exist; check the package’s source for disable options.)
Log Output
Add debug logs to the BeautifySpecify class to trace formatting logic:
\Log::debug('Specify output:', ['raw' => $rawOutput]);
Fallback to Plain Output If the package fails, revert to default PHPUnit output by removing the service provider or using a plain PHPUnit extension.
Custom Formatters
Extend the BarthyKoeln\BeautifySpecify\Formatters\SpecifyFormatter class to add new output styles (e.g., emojis, icons).
Event Listeners
Hook into PHPUnit’s events (e.g., TestListener) to pre-process output before formatting:
PHPUnit\Runner\AfterLastTestMethod::class => function ($event) {
// Modify $event->result before beautification
};
Template Overrides Replace the default output template by binding a custom formatter in the service provider:
$this->app->bind(
'beautify-specify.formatter',
CustomFormatter::class
);
How can I help you explore Laravel packages today?