Skip to content

Optionally repeat TestDox output for non-successful tests after the regular TestDox output#5885

Merged
sebastianbergmann merged 2 commits intomainfrom
optionally-repeat-testdox-output-for-non-successful-tests
Jul 1, 2024
Merged

Optionally repeat TestDox output for non-successful tests after the regular TestDox output#5885
sebastianbergmann merged 2 commits intomainfrom
optionally-repeat-testdox-output-for-non-successful-tests

Conversation

@sebastianbergmann
Copy link
Copy Markdown
Owner

@sebastianbergmann sebastianbergmann commented Jul 1, 2024

  • Implement testdoxSummary attribute on the <phpunit> element of the XML configuration file
  • Implement --testdox-summary CLI option
  • Merge the above into PHPUnit\TextUI\Configuration\Configuration::testDoxOutputWithSummary()
  • Pass the aforementioned flag to PHPUnit\TextUI\Output\TestDox\ResultPrinter and act on it
  • Implement automated end-to-end tests for this new functionality

Example: --testdox --testdox-summary

❯ ./phpunit --testdox --testdox-summary ~/ExampleTest.php
PHPUnit 11.3-g4cde41c5f8 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.8
Configuration: /usr/local/src/phpunit/phpunit.xml

.FR                                                                 3 / 3 (100%)

Time: 00:00.018, Memory: 10.00 MB

Example
 ✔ Succeeds
 ✘ Fails
   ┐
   ├ Failed asserting that false is true.
   │
   │ /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:98
   │ /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:51
   │ /usr/local/src/phpunit/src/Framework/Assert.php:1973
   │ /usr/local/src/phpunit/src/Framework/Assert.php:940
   │ /home/sb/ExampleTest.php:13
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:1201
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:498
   │ /usr/local/src/phpunit/src/Framework/TestRunner/TestRunner.php:84
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:349
   │ /usr/local/src/phpunit/src/Framework/TestSuite.php:387
   │ /usr/local/src/phpunit/src/TextUI/TestRunner.php:62
   │ /usr/local/src/phpunit/src/TextUI/Application.php:201
   ┴
 ⚠ Risky

Summary of tests with errors, failures, or issues:

Example
 ✘ Fails
   ┐
   ├ Failed asserting that false is true.
   │
   │ /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:98
   │ /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:51
   │ /usr/local/src/phpunit/src/Framework/Assert.php:1973
   │ /usr/local/src/phpunit/src/Framework/Assert.php:940
   │ /home/sb/ExampleTest.php:13
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:1201
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:498
   │ /usr/local/src/phpunit/src/Framework/TestRunner/TestRunner.php:84
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:349
   │ /usr/local/src/phpunit/src/Framework/TestSuite.php:387
   │ /usr/local/src/phpunit/src/TextUI/TestRunner.php:62
   │ /usr/local/src/phpunit/src/TextUI/Application.php:201
   ┴
 ⚠ Risky

There was 1 risky test:

1) ExampleTest::testRisky
This test did not perform any assertions

/home/sb/ExampleTest.php:16

FAILURES!
Tests: 3, Assertions: 2, Failures: 1, Risky: 1.

Example: --testdox

❯ ./phpunit --testdox ~/ExampleTest.php
PHPUnit 11.3-g4cde41c5f8 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.8
Configuration: /usr/local/src/phpunit/phpunit.xml

.FR                                                                 3 / 3 (100%)

Time: 00:00.010, Memory: 10.00 MB

Example
 ✔ Succeeds
 ✘ Fails
   ┐
   ├ Failed asserting that false is true.
   │
   │ /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:98
   │ /usr/local/src/phpunit/src/Framework/Constraint/Constraint.php:51
   │ /usr/local/src/phpunit/src/Framework/Assert.php:1973
   │ /usr/local/src/phpunit/src/Framework/Assert.php:940
   │ /home/sb/ExampleTest.php:13
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:1201
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:498
   │ /usr/local/src/phpunit/src/Framework/TestRunner/TestRunner.php:84
   │ /usr/local/src/phpunit/src/Framework/TestCase.php:349
   │ /usr/local/src/phpunit/src/Framework/TestSuite.php:387
   │ /usr/local/src/phpunit/src/TextUI/TestRunner.php:62
   │ /usr/local/src/phpunit/src/TextUI/Application.php:201
   ┴
 ⚠ Risky

There was 1 risky test:

1) ExampleTest::testRisky
This test did not perform any assertions

/home/sb/ExampleTest.php:16

FAILURES!
Tests: 3, Assertions: 2, Failures: 1, Risky: 1.

@sebastianbergmann sebastianbergmann added type/enhancement A new idea that should be implemented feature/testdox The TextDox printer/formatter feature/configuration/xml feature/configuration/cli labels Jul 1, 2024
@sebastianbergmann sebastianbergmann added this to the PHPUnit 11.3 milestone Jul 1, 2024
@codecov
Copy link
Copy Markdown

codecov Bot commented Jul 1, 2024

Codecov Report

Attention: Patch coverage is 91.07143% with 5 lines in your changes missing coverage. Please review.

Project coverage is 92.44%. Comparing base (bb24b27) to head (32ceefc).

Files Patch % Lines
src/TextUI/Output/TestDox/ResultPrinter.php 84.61% 4 Missing ⚠️
src/TextUI/Configuration/Cli/Configuration.php 88.88% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #5885      +/-   ##
============================================
+ Coverage     92.43%   92.44%   +0.01%     
- Complexity     6566     6583      +17     
============================================
  Files           700      700              
  Lines         19791    19837      +46     
============================================
+ Hits          18293    18339      +46     
  Misses         1498     1498              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@sebastianbergmann sebastianbergmann marked this pull request as ready for review July 1, 2024 14:43
@sebastianbergmann sebastianbergmann merged commit b84e35d into main Jul 1, 2024
@sebastianbergmann sebastianbergmann deleted the optionally-repeat-testdox-output-for-non-successful-tests branch July 1, 2024 14:45
@tarlepp
Copy link
Copy Markdown

tarlepp commented Jul 1, 2024

@sebastianbergmann Thank you to bring this feature back!

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 17, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

feature/configuration/cli feature/configuration/xml feature/testdox The TextDox printer/formatter type/enhancement A new idea that should be implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants