Posted by opdavies on June 19, 2018 at 5:40pm
Start:
2018-06-27 18:30 - 21:00 Europe/London Organizers:
Event type:
User group meeting
This month we're doing something a little different - a workshop on automated testing with Drupal. If you want to learn more about automated testing, or if you're not sure how to start testing your Drupal modules, we'll cover some of the theory before writing our first test and building up a new module from scratch.
You will need to bring a laptop with a Drupal 8 site running. There is a pre-configured environment available at GitHub - opdavies/drupal-testing-workshop which uses Docksal and has it's PHPUnit add-on installed
Venue
Microserve Ltd
11th Floor, Colston Tower
Bristol
BS1 4XE

Comments
Microserve
Confirmed that we're hosting it at the Microserve office (11th floor, Colston Tower).
https://www.oliverdavies.uk
Going to actually make this one
Will give Docksal a go.
Install docksal on windows 7 and setting up the example
All seems to go well. I get a drupal website that I can login to as admin. Try running tests blindly as instructed and get:
{ drupal-testing-workshop } master » fin phpunit web/modules/contrib/examples/phpunit_example
Copying /var/www/.docksal/drupal/core/phpunit.xml to /var/www/web/core/phpunit.xml
PHPUnit 6.5.8 by Sebastian Bergmann and contributors.
Testing web/modules/contrib/examples/phpunit_example
E
Time: 8.56 seconds, Memory: 6.00MB
There was 1 error:
1) Drupal\Tests\phpunit_example\Functional\PHPUnitExampleMenuTest::testPhpUnitExampleLink
Exception: You must provide a SIMPLETEST_BASE_URL environment variable to run some PHPUnit based functional tests.
/var/www/web/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:544
/var/www/web/core/tests/Drupal/Tests/BrowserTestBase.php:486
ERRORS!
Tests: 1, Assertions: 0, Errors: 1.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Looks like I need to investigate this ...
https://www.drupal.org/project/drupal/issues/2799053
Hi Tim, I've added a commit
Hi Tim,
I've added a commit to the repo to fix this - https://github.com/opdavies/drupal-testing-workshop/commit/6e90680347eb3.... You can add these values into core/phpunit.xml and re-run "fin phpunit".
Alternatively, run "git pull", remove core/phpunit.xml and re-run "fin phpunit". I've added those values into the stub phpunit.xml that gets copied and used.
https://www.oliverdavies.uk
Fixed
Nice one Ollie.
Thanks for the help, that works now.
Fantastic
Fantastic!
https://www.oliverdavies.uk
We're in the boardroom on the
We're in the boardroom on the 11th floor of Colston Tower. Text me if anyone has any issues getting into the building, or I'm keeping an eye on the @drupalbristol Twitter account.
https://www.oliverdavies.uk
We're in the boardroom on the
We're in the boardroom on the 11th floor of Colston Tower. Text me if anyone has any issues getting into the building, or I'm keeping an eye on the @drupalbristol Twitter account.
https://www.oliverdavies.uk
Thanks everyone for coming
Thanks everyone for coming along this evening. Hopefully it was useful, and you enjoyed something a bit different to the usual talks night.
It was my first workshop, so any feedback would be appreciated and well received! :)
https://www.oliverdavies.uk
Slides and code
Here are the slides from last night - https://speakerdeck.com/opdavies/drupal-testing-workshop.
Also, here is the code from the exercises. https://github.com/opdavies/drupal-testing-workshop-exercises.
It's just one commit at the moment that adds everything, but I'll split it into different commits to show each step and tag each end of test for future reference I've renamed the module from "drupalbristol" to "drupaltest", but the rest of the code is the same and the tests still pass. :)
Feel free to contact me with any questions, and happy testing!
https://www.oliverdavies.uk
Really useful
It was a really useful evening, thanks for your time and effort Ollie.
Went very well from my point of view, my only feedback would be it would be useful to have another source for people to copy the code bits from from (handouts?), I don't think a digital source would be good as there actually is a benefit from hitting the keys and working through any typos you make.
Thanks
Thanks for the feedback. I was thinking the same thing - it wasn't great having to switch back and forth between the different slides whilst people were typing them out. Agreed that actually pressing the keys is better than just copying and pasting from GitHub, which is why I didn't link to that repo until afterwards, but I do think handouts could work well. I'll give that a try if I do this as a workshop again.
https://www.oliverdavies.uk
Great evening
Thanks Ollie for last night. It helped a lot.
I finally got around to having a proper look at testing, I've even got a project in mind where testing would definitely be of benefit and the client may actually pay for the extra time to develop them.
Agree with Chris that it would be good to be able to copy code examples from elsewhere. Either handouts, but maybe something online, like a screenshot of the code to stop blindly copying and paste.
Thanks also for posting the examples, once I've found out why I didn't get a samba share setup i'll go through them again.
Good luck with the talks next week.
Agree with Chris that it
Screenshots could work too, or I could export the PDFs or images of the slides beforehand. Thanks for the idea! :)
Andrew's been using Docksal with Windows. I'll ask him tomorrow how his shares are set up.
https://www.oliverdavies.uk