phpunit-slow-test-detector icon indicating copy to clipboard operation
phpunit-slow-test-detector copied to clipboard

Add JUnit report logger

Open HypeMC opened this issue 6 months ago • 3 comments

This pull request adds the ability to generate a JUnit log file for slow tests. Currently, when reviewing a PR, one must go to the CI output to see if there are any slow tests. Now, a JUnit log file can be generated instead and used with GitHub actions:

- name: Publish Slow Test Report
  uses: mikepenz/action-junit-report@v3
  if: always()
  with:
    check_name: PHPUnit Slow Tests Report
    annotate_only: 'true'
    report_paths: ./slow-tests.xml

This makes it easier and more clear to spot slow tests:

image

To trigger the file generation, all that's required is to add the name of the file to phpunit.xml:

<bootstrap class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
  <parameter name="junit-file" value="slow-tests.xml"/>
</bootstrap>

If PHPUnit is run with the --log-junit= option and the junit-file parameter is present, the JUnit log for slow tests is generated.

Later, if needed, other formats such as testdox could be added.

HypeMC avatar Jan 06 '24 07:01 HypeMC