Unit Test in Drupal 8
Drupal Camp Cebu 2018
Who am I?
•
•
•
•
•
Table of contents
● What is Unit Test
● Unit Test in Drupal, particularly in Drupal 8
● Unit Test Setup
● Unit Test Demonstration
● Q&A
What is Unit Test?
A software development process in which the smallest testable parts of an application, called units, are
individually and independently scrutinized for proper operation.
Reference: https://searchsoftwarequality.techtarget.com/definition/unit-testing
Unit Test in Drupal, particularly in Drupal 8
● Drupal 7 → Simpletest; Drupal 8 → PHPUnit
● Type of tests
○ Unit Test
○ Kernel Test
○ Functional Test
Unit Test Setup
● Install Drupal 8, PHPUnit already comes with it
● Install Simpletest module
Unit Test Setup
● Setup the test directory
○
Unit Test Setup
● Code setup
Unit Test Setup
● Running the test (from UI):
Unit Test Setup
● Running the test (from UI):
Unit Test Setup
● Running the test (from UI):
Unit Test Setup
● Running the test (from UI):
Unit Test Setup
● Running the test (from command line):
Unit Test Setup
● Running the test (from command line):
Unit Test Demonstration
….
Q&A?
References
● https://www.drupal.org/docs/8/phpunit
● https://www.lullabot.com/articles/an-overview-of-testing-in-drupal-8
● https://phpunit.de/manual/6.5/en/installation.html
● https://phpunit.readthedocs.io/en/7.4
Thank you!

Unit test in drupal 8 by Pratomo Ardianto Drupalcamp Cebu 2018