You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
phpunit --testdox does not show previous exception.
Current behavior
(good) Output for phpunit ExampleTest.php without --testdox shows outer and inner exception.
(bad) Output for phpunit --testdox ExampleTest.php shows outer exception, but not the inner (previous) exception.
~/projects/phplib/phpunit-test $ ./vendor/bin/phpunit --testdox ExampleTest.php
PHPUnit 11.2.1 by Sebastian Bergmann and contributors.
Runtime: PHP 8.2.15
E 1 / 1 (100%)
Time: 00:00.008, Memory: 4.00 MB
Example
✘ Foo
│
│ Exception: Outer
│
│ /home/lemonhead/projects/phplib/phpunit-test/ExampleTest.php:10
│
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
How to reproduce
mkdir testdir
cd testdir
composer require phpunit/phpunit
nano ExampleTest.php
The `--testdox` parameter replaces the printer we previously set with `--printer`.
This causes the following problems:
- The previous exception is not shown, see sebastianbergmann/phpunit#5863
- The "HTML output was generated" message from Drupal is not shown.
By removing the argument we fall back to the Drupal output printer. A developer can still manually append --testdox when running `ddev phpunit`.
The `--testdox` parameter replaces the printer we previously set with `--printer`.
This causes the following problems:
- The previous exception is not shown, see sebastianbergmann/phpunit#5863
- The "HTML output was generated" message from Drupal is not shown.
By removing the argument we fall back to the Drupal output printer. A developer can still manually append --testdox when running `ddev phpunit`.
Summary
phpunit --testdox
does not show previous exception.Current behavior
(good) Output for
phpunit ExampleTest.php
without--testdox
shows outer and inner exception.(bad) Output for
phpunit --testdox ExampleTest.php
shows outer exception, but not the inner (previous) exception.How to reproduce
mkdir testdir cd testdir composer require phpunit/phpunit nano ExampleTest.php
Put the following php code:
Run these commands:
Expected behavior
Output for both commands contains "Exception: Outer" and "Exception: Inner".
Related issues
There are other issues and PRs that deal with showing previous exception in different use cases.
But it seems this was not done yet for testdox.
About my use case
I personally would not mind to run the test without
--testdox
.But I am currently using a tool that adds
--testdox
parameter by default. See https://github.com/ddev/ddev-drupal-contrib/blob/903026a2fef564b1b7b1fb54213ebb669267995b/commands/web/phpunit#L21For the steps above I isolated the problem to a minimal project with the latest phpunit I get with composer.
The text was updated successfully, but these errors were encountered: