Closed (duplicate)
Project:
Drupal core
Version:
8.7.x-dev
Component:
documentation
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2019 at 17:33 UTC
Updated:
20 Feb 2019 at 19:16 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
jhodgdonComment #3
dwwYes please! Ditto core/tests/README.md which is also wildly stale, especially wrt FunctionalJavascript tests.
Comment #4
dwwhttps://www.drupal.org/docs/8/phpunit/running-phpunit-tests fails to mention you have to modify phpunit.xml to get FunctionalJavascript tests to work, and it talks about PhantomJS (which, AFAIK, is no longer needed/recommended/used). If you forget, they all silently pass, even if you have
$this->assertTrue(FALSE). That should probably be a separate bug report. Maybe that's a run-tests.sh bug.https://www.drupal.org/docs/8/phpunit/phpunit-javascript-testing-tutorial seems reasonably up-to-date, but core/tests/README.md is woefully behind the times.
Another evil pain point: if you configure your phpunit.xml to get the JS tests to work, everything else fails along these lines:
Argh. I sure wish there was a simple way to actually configure a core checkout to run all the tests locally. ;)
Comment #5
dwwAhh, great. The run-tests.sh bug from the first part of #4 is here: #2905007: Allow run-tests.sh to report skipped/incomplete PHPUnit tests. Glad that's already known. ;)
Comment #6
dwwRe: #4 "Another evil pain point...", turns out that defining
<env name="MINK_DRIVER_CLASS" value="Drupal\FunctionalJavascriptTests\DrupalSelenium2Driver"/>is totally unnecessary and causes trouble. I removed it from that handbook page.Comment #7
dwwFrom Slack:
alexpott: @dww One day we should totally re-organise these docs
alexpott: Top level: Types of tests, Running tests, Writing tests
alexpott: Inside running tests - separate pages for each type and a page on phpunit.xml configs
alexpott: inside writing tests - section per test type
I couldn't agree more. ;) Pasting here for reference.
Note: he's actively in the middle of that rearrangement as I type this...
Comment #8
dwwFYI: @alexpott and I have done a fair bit of review, re-org, re-testing, and edits to the PHPUnit in Drupal 8 guide. In particular, these pages are now pretty much right:
https://www.drupal.org/docs/8/phpunit/running-phpunit-tests
https://www.drupal.org/docs/8/phpunit/running-phpunit-javascript-tests
https://www.drupal.org/docs/8/phpunit/phpunit-javascript-test-writing-tu...
Comment #9
jhodgdonOK, based on the links in #8, here is the first pass at a Core patch to update the shipped docs. I took out large sections of docs and pared it down to what I hope is the essentials, and am only talking about non-deprecated test classes now I hope.
By the way, I don't think https://www.drupal.org/docs/8/phpunit/phpunit-javascript-test-writing-tu... has been completely updated. It still mentions JavascripTestBase instead of WebDriverBase at the top. I stopped reading there.
Comment #10
lendudereally nice! Couple of things:
missing period at the end
This is true for Simpletest but not for PHPUnit tests, which can use @dataProvider
is this really needed? not that I know.
any reason why the entire nightwatch section is removed?
Comment #11
jhodgdonThanks for the review!
I'll take care of the nitpicks shortly...
Regarding the PHP version, I took that from
https://www.drupal.org/docs/8/phpunit/running-phpunit-javascript-tests
Happy to change it; if so we should also change that page.
Regarding Nightwatch, do we still have Nightwatch tests in Core? If so, what is the base class, because we should add it to the api.php changes too. But I do not see anything in Core 8.7.x on api.drupal.org that has Nightwatch in the name -- no namespaces or classes. ???
Comment #12
alexpottspelling: dependencies
I'm not sure where this comes from but I think this doesn't belong here. I think it can be merged into the next section - specifically the bits about BROWSERTEST_OUTPUT_DIRECTORY (which I think this is trying to help you set up) and the printerClass thingy.
Or maybe this is saying that in order to run tests you need a
sites/simpletestthat is writable by both the user running the tests and the webserver? If so that's not debug output. That's the site directory of the site under test which includes its file directory, twig cache, its settings.php, etc...This is not necessarily true. It depends on how your file system is set up and works and how you run the tests. Not everyone needs to do this. I might put this in a troubleshooting section.
Comment #13
jhodgdonTalked this over with @lendude a bit in Slack. Here's a new patch.
- I left in the PHP 7.1 thing as it's from
https://www.drupal.org/docs/8/phpunit/running-phpunit-javascript-tests
- Fixed the nitpicks
- Added a short paragraph to core.api.php part for Nightwatch
- Restored the Nightwatch section in the README
- A few other minor changes, see interdiff -- mostly making the distinction between Nightwatch JS and PHP-based JS tests
Comment #14
jhodgdon#12 came while I was making that patch and uploading... Here is a new patch to address #12.
Comment #15
jhodgdonWhile trying to use the instructions in the README and on the test pages to run tests, I ran into a small problem. Updating README accordingly...
Comment #16
jhodgdonTrying to write my own test... Found another error... updating core.api.php file this time.
Comment #17
jhodgdonHumph. It turns out that the browser output directory is not actually currently configurable:
#2992069: setUpHtmlOutput, initBrowserOutputFile and htmlOutput use browser output directory differently
Do we want to document this in the README or wait for that issue to be fixed?
Comment #18
jhodgdonDang, I just realized there was another issue about this. We need to close one as a duplicate and credit people who worked on either I think?
Comment #19
dwwAlas. Oh well. #2949715 is the older issue, so this should be closed as the dup. We can merge efforts over there. I see you and @alexpott are already involved, so it's just me and @Lendude who have to move over.
Cheers,
-Derek