Last active
February 25, 2025 14:45
-
-
Save ngunyimacharia/916d0f9237bc6f86d9c579e7a020fad0 to your computer and use it in GitHub Desktop.
PHPUnit `report.xml` analysis
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $xmlFile = 'report.xml'; // Update with the actual XML file path | |
| if ( ! file_exists($xmlFile)) { | |
| die("Error: PHPUnit report file not found.\n"); | |
| } | |
| $xml = simplexml_load_file($xmlFile); | |
| foreach ($xml->testsuite as $suite) { | |
| foreach ($suite->testsuite as $subSuite) { | |
| foreach ($subSuite->testsuite as $testcase) { | |
| $name = | |
| (string) $testcase['classname'].'::'.(string) $testcase['name']; | |
| $time = (float) $testcase['time']; | |
| $tests[$name] = $time; | |
| } | |
| } | |
| } | |
| arsort($tests); // Sort by time in descending order | |
| echo "All PHPUnit Tests Ordered by Duration:\n"; | |
| foreach ($tests as $test => $time) { | |
| echo "$test - $time sec\n"; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Report generated using
./vendor/bin/phpunit --log-junit report.xml