Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Follow-up to #2811065: Fix docs around --printer option in phpunit.xml.dist
Problem/Motivation
From #2811065-12: Fix docs around --printer option in phpunit.xml.dist
AFAICT, the printerClass definition works, and does not break PHPStorm any more. 2016.3 EAP, October 19, 2016.
Proposed resolution
https://youtrack.jetbrains.com/issue/WI-24808 is resolved so add the printerClass to phpunit.xml.dist
Remaining tasks
- Verify it.
- RTBC if fixed.
- Report a jetbrains bug if not fixed.
User interface changes
None
API changes
None
Data model changes
None
Comment | File | Size | Author |
---|---|---|---|
#45 | 2870145-45.patch | 1.06 KB | tstoeckler |
#27 | SimpletestUiPrinter.png | 404.63 KB | alexpott |
#27 | HtmlOutputPrinter.png | 195.51 KB | alexpott |
Comments
Comment #2
jibranHere is the patch.
Comment #3
jibranI'm on PhpStrom 2017.1.2 and Unit, KTB and Functional tests are working just fine for me.
Comment #5
dawehnerI tried it out and sadly it doesn't work as in doesn't actually show any HTML links in phpstorm, but it does not longer fail to run the tests. Nice find @jibran!
Comment #7
Wim LeersI'd love this to happen. Massive DX improvement.
Comment #8
valthebaldComment #9
Wim Leers👏
Comment #10
vijaycs85Spent some time figure out the test failure. Here is my findings:
The failing test was introduced by #2809117: Integrate PHPUnit verbose output in Simpletest UI to confirm that the HTML format report generated when run tests via simpletest UI. Failing test prove(?) that use of HtmlOutputPrinter instead of SimpletestUiPrinter.
The test(
\Drupal\simpletest\Tests\UiPhpUnitOutputTest
) explicitly try to run sample test (incore/modules/simpletest/tests/fixtures/simpletest_phpunit_browsertest.php
) usingsimpletest_phpunit_run_command()
which explicitly sets--printer=SimpletestUiPrinter
not HtmlOutputPrinter. I also tried to print the command gettingexec()
locally to confirm this:In theory, this change shouldn't cause the failure.
I have tried few scenarios:
1.
Drupal\simpletest\Tests\UiPhpUnitOutputTest
locally always fails (with & without this issue change). I am running it using below command:2. Thought it was Drupal CI issue and tried to run with non-functional change in phpunit.xml.dist (#1970534-164: Patch testing issue) and all green.
3. Made sure this is still an issue in current HEAD #1970534-162: Patch testing issue
btw, removed 'novice' tag as it looks bit complex.
Comment #11
valthebaldEmpirically (I could not found any reference proving that) I've found that printerClass in configuration file wins over --printer command line parameter.
Comment in phpunit.xml.dist suggesting to change printerClass HtmlOutputPrinter was added in #2760905: The documentation should be more explicit about PHPUnit requesting the webserver user to perform all functional tests, before SimpletestUiPrinter even existed (introduced in #2809117: Integrate PHPUnit verbose output in Simpletest UI).
Since SimpletestUiPrinter is direct successor of HtmlOutputPrinter, and only makes output formatting more readable, maybe it will make sense to set printer class to SimpletestUiPrinter? (patch attached)
Comment #13
valthebaldPatch against latest HEAD
Comment #14
vijaycs85awesome. not sure how, but it's back to green :) as mentioned in #10, change shouldn't case any test fail. Let's get it in!
Comment #15
valthebaldWill it make sense to remove explicit setting of printerClass from --printer CLI parameter (simpletest.module around line 337):
?
We already have test that checks that SimpletestUIPrinter is used
Comment #17
valthebaldI'm sure the last testbot failure has nothing to do with phpunit.xml.dist change, but that's a good opportunity to check if removal of `--printer` option would work
Comment #19
valthebaldBack to 'Needs review' because of aborted CI job
Comment #20
valthebaldLooks like - - printer CLI option is not needed anymore
Comment #21
vijaycs85Looks good.
Comment #22
larowlanThis isn't the same thing - so I think we should add some documentation here telling people they have the option of overriding this in their phpunit.xml to use the HtmlOutputPrinter
Comment #23
valthebaldAdded comment in phpunit.xml.dist
Comment #24
valthebaldFix wording
Comment #25
valthebald...and move comment closer to printerClass line (as it was in previous TODO comment)
Comment #26
neerajsinghPatch at #25 looks good to me.
Comment #27
alexpott@valthebald I'm not sure I agree with using SimpletestUiPrinter over HtmlOutputPrinter. The expected output from running PHPUnit is not links marked up in HTML and adding HTML does not improve readability from the CLI - I think it makes readability worse.
See attached screenshots.
we should leave this as it was. run-tests.sh manages stripping the html as appropriate.
This should be HtmlOutputPrinter and not SimpletestUiPrinter
Comment #28
alexpottDiscussed in slack with @valthebald. Unfortunately in PHPUnit 4.8 once the printer class is set in the phpunit.xml.dist it can't be overridden from the command line. So setting class to
SimpletestUiPrinter::class
insimpletest_phpunit_run_command()
won't work. However this is fixed in PHPUnit 6.5 so we will be able to do once PHPUnit 4 is dropped from core. That might happen if we decide to test PHP 7.0 and PHP 7.1 using PHPUnit 6 as well and once we drop support for PHP 5.5 and 5.6.For more about all of that see #2932606: Use PHPUnit 6 for PHP 7.0 / 7.1 testing and its related issues.
Comment #29
Wim LeersWoah … my head is spinning with those competing requirements … 😱 🤯
Comment #31
heddnAlso of note, https://youtrack.jetbrains.com/issue/WI-24808 is no longer a blocker either. And the postponed issue is also closed. So... let's keep things moving.
Comment #32
alexpottWe'll still be use PHPUnit 4 until we drop PHP 5.5. That's not happened yet.
Comment #33
tstoecklerJust a minor point, and maybe you actually meant it that way, but I think it was fixed in 5.0 already.
See https://github.com/sebastianbergmann/phpunit/blob/49f1c93ee37d10ffba6ce2... or https://github.com/sebastianbergmann/phpunit/commit/b191e125cb130427b396...
Comment #34
alexpott@tstoeckler good spot.
But we're not going to use PhpUnit 5 :)
Comment #35
valthebaldRare case where "postponed" status has clear "until" date - March 2019 :)
Comment #36
Wim LeersCool, so let's make that clear in the issue title for when people scan their issue tracker!
Comment #38
tstoecklerMarked #3028974: Enable printerClass in phpunit.xml.dist as duplicate
Comment #39
heddnIs this pending on the opening of 8.8 or can it land in 8.7? If it is the later, this can land now. Let's make this more explicit.
Comment #40
alexpott8.8 unfortunately.
8.7 will have best effort PHP5 support.
Comment #41
DamienMcKenna@alexpott: Given that 8.7 won't be out to May, would you mind clarifying why this can't be changed before then?
Comment #43
tstoecklerHit this again today... now that #3008870: Drop support for PHPUnit 4.8 once PHP 5 is no longer supported (8.8.x) is (just!) in we can finally do this. Yay!
Comment #44
alexpottThis feels like TMI now - talking about PHPStorm 2016.2.2 in 2019...
Also this text should wrap at 80.
Comment #45
tstoecklerI agree. I also agree that
HtmlOutputPrinter
makes more sense thanSimpletestUiPrinter
by default.Here's is a minimal patch, analogous to #2
Comment #46
jibranHtmlOutputPrinter
it is.Comment #47
alexpottCrediting @vijaycs85 for testing the patch and the explanatory comment in #10.
Crediting @larowlan for reviewing and asking for HtmlOutputPrinter
Comment #48
alexpottCommitted 0b95d68 and pushed to 8.8.x. Thanks!