shawnveltman / testmetrics
A few helpers to profile your test suite
Requires
- php: ^8.0|^8.1
- ext-simplexml: *
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- laravel/pint: ^1.0
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-10-28 00:13:26 UTC
README
An easy way to find slow tests within your application. Since Laravel Parallel Testing allows for JUnit logging, this is simply a JUnit xml parser that grabs simple stats (setup time, average test time after setup) for each test suite, to hilight those that are the slowest.
Installation
You can install the package via composer:
composer require shawnveltman/testmetrics
After installation, be sure to add the following lines to your phpunit.xml file:
<logging> <junit outputFile="junit.xml"/> </logging>
Finally, be sure to add the junit.xml to your gitignore.
Usage
Now, after you run your parallel tests, you will have the junit.xml file. Grab the contents of that file as a string, and pass it to the test_results_parser method, then print your results. That's it!
$testmetrics = new Shawnveltman\Testmetrics(); echo $testmetrics->test_results_parser(contents: $file_contents)->print_results();
Alternately, you can pass a filepath instead of string contents.
$testmetrics = new \Shawnveltman\Testmetrics\Testmetrics(); $path = base_path('junit.xml'); echo $testmetrics->test_results_parser(path: $path)->print_results();
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.