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 1 year 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

Codecov Report

Attention: 73 lines in your changes are missing coverage. Please review.

Comparison is base (e55d27d) 69.86% compared to head (6e09889) 67.20%. Report is 35 commits behind head on main.

Files Patch % Lines
src/Extension.php 0.00% 36 Missing :warning:
src/Logger/LoggerFactory.php 0.00% 28 Missing :warning:
src/Reporter/NullReporter.php 0.00% 4 Missing :warning:
src/Logger/NullLogger.php 0.00% 3 Missing :warning:
src/FileWriter/DefaultFileWriter.php 88.88% 2 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##               main     #458      +/-   ##
============================================
- Coverage     69.86%   67.20%   -2.66%     
- Complexity      110      155      +45     
============================================
  Files            26       38      +12     
  Lines           521      677     +156     
============================================
+ Hits            364      455      +91     
- Misses          157      222      +65     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Jan 06 '24 07:01 codecov[bot]

Apologies for the delay, @HypeMC, I'm taking a look at this now!

localheinz avatar Apr 08 '24 06:04 localheinz

@localheinz No problem, I can rebase if needed since there are conflicts, but I don't wanna do it while you're reviewing.

HypeMC avatar Apr 08 '24 09:04 HypeMC