Automated Testing: PHPUnit all the way

Download slides

This core conversation will provide some insights into Drupal core’s testing strategies, what works well and what we are in the process of improving. One major effort is to convert our whole test code and infrastructure to use PHPUnit and to deprecate SimpleTest. This session is targeted at core and contrib developers alike, since the same testing knowledge can be applied to contributed modules as well. We expect that you have worked on a test case at least once, but will explain PHPUnit and concepts otherwise.

We will talk about:

  • Different types of tests: unit tests vs. integration tests vs. functional tests vs behavioral tests vs. white box tests vs. black box tests

  • The case for PHPUnit and why we move away from SimpleTest

  • Explaining test flavors in Drupal: Unit tests, Kernel tests, Browser tests, Javascript Browser tests

  • Converting SimpleTests to Browser tests

  • Assertions: checking the outcome of your scenario

  • Strict assertions in PHPUnit vs. lax assertions in SimpleTest

  • Mocking in unit tests: advantages of using the Prophecy framework (part of PHPUnit)

  • Test fixtures and the @dataProvider annotation concept of PHPUnit

  • Test predictability: Avoiding random data in tests

  • Test simplicity: avoiding complex logic in tests, hard code everything

  • Test abstractions: how much is too much?

  • t() calls and translations in tests

  • Testing exceptions: @expectedException annotations and why they are deprecated

Session Track

Coding and Development

Experience level

Intermediate

Drupal Version

Drupal 8.4.x

Session Time Slot(s)

Time: 
09/27/2016 - 17:00 to 09/27/2016 - 18:00
Room: 
Liffey Hall 1 | Pantheon